$ npm i egg-mongoose-logger --save
// {app_root}/config/plugin.js
exports.mongooseLogger = {
enable: true,
package: 'egg-mongoose-logger',
};
// {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.
Please open an issue here.