| import debug from 'debug'; |
| |
| function debugPouch(PouchDB) { |
| PouchDB.debug = debug; |
| var logs = {}; |
| /* istanbul ignore next */ |
| PouchDB.on('debug', function (args) { |
| // first argument is log identifier |
| var logId = args[0]; |
| // rest should be passed verbatim to debug module |
| var logArgs = args.slice(1); |
| if (!logs[logId]) { |
| logs[logId] = debug('pouchdb:' + logId); |
| } |
| logs[logId].apply(null, logArgs); |
| }); |
| } |
| |
| // TODO: add a window.PouchDB.plugin() call for the benefit of <script> users before we |
| // release this as a separate plugin in PouchDB 7.0.0. |
| |
| export default debugPouch; |