mirror of
https://github.com/strapi/strapi.git
synced 2025-07-12 19:41:10 +00:00
38 lines
579 B
JavaScript
38 lines
579 B
JavaScript
'use strict';
|
|
|
|
/**
|
|
* Logger hook
|
|
*/
|
|
|
|
module.exports = function (strapi) {
|
|
const hook = {
|
|
|
|
/**
|
|
* Default options
|
|
*/
|
|
|
|
defaults: {
|
|
logger: true
|
|
},
|
|
|
|
/**
|
|
* Initialize the hook
|
|
*/
|
|
|
|
initialize: function (cb) {
|
|
if (strapi.config.logger === true) {
|
|
strapi.app.use(function * (next) {
|
|
const start = new Date();
|
|
yield next;
|
|
const ms = new Date() - start;
|
|
strapi.log.debug(this.method + ' ' + this.url + ' (' + ms + 'ms)');
|
|
});
|
|
}
|
|
|
|
cb();
|
|
}
|
|
};
|
|
|
|
return hook;
|
|
};
|