/egg-mongoose-logger

:egg:A helper plugin to hook egg logger library in mongoose.

Primary LanguageJavaScriptMIT LicenseMIT

egg-mongoose-logger

NPM version build status Test coverage David deps Known Vulnerabilities npm download

Install

$ npm i egg-mongoose-logger --save

Usage

// {app_root}/config/plugin.js
exports.mongooseLogger = {
  enable: true,
  package: 'egg-mongoose-logger',
};

Configuration

// {app_root}/config/config.default.js
exports.mongooseLogger = {
  debug: true,
  // custom formatter, optional
  formatter: function(meta) {
    const query = JSON.stringify(meta.query);
    const options = JSON.stringify(meta.options || {});
    return `db.getCollection('${meta.collectionName}').${meta.methodName}(${query}, ${options})`;
  },
};

see config/config.default.js for more detail.

Example

Questions & Suggestions

Please open an issue here.

License

MIT