| {% include anchor.html edit="true" title="Debug mode" hash="debug_mode" %} |
| |
| PouchDB uses the [debug](https://www.npmjs.org/package/debug) module for fine-grained debug output. |
| |
| |
| {% include alert/start.html variant="warning"%} |
| {% markdown %} |
| |
| This `debug()` API is currently part of PouchDB core. However, in PouchDB v7.0.0 it will be moved to a separate plugin. |
| |
| {% endmarkdown %} |
| {% include alert/end.html%} |
| |
| To enable debug mode, just call: |
| |
| {% highlight js %} |
| PouchDB.debug.enable('*'); |
| {% endhighlight %} |
| |
| In your browser console, you should then see something like this: |
| |
| {% include img.html src="debug_mode.png" alt="Coloured Log Output" %} |
| |
| In Node.js, you can also set a command-line flag: |
| |
| {% highlight bash %} |
| DEBUG=pouchdb:* node myscript.js |
| {% endhighlight %} |
| |
| You can also enable debugging of specific modules. Currently we only have `pouchb:api` (API-level calls) and `pouchdb:http` (HTTP requests): |
| |
| {% highlight js %} |
| PouchDB.debug.enable('pouchdb:api'); // or |
| PouchDB.debug.enable('pouchdb:http'); |
| {% endhighlight %} |
| |
| These settings are saved to the browser's LocalStorage. So to disable them, you must call: |
| |
| {% highlight js %} |
| PouchDB.debug.disable(); |
| {% endhighlight %} |
| |
| Your users won't see debug output unless you explicitly call `PouchDB.debug.enable()` within your application code. |