| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | 1x | // A hook that logs service method before, after and error
const logger = require('winston')
export function log (hook) {
let message = `${hook.type}: ${hook.path} - Method: ${hook.method}`
if (hook.type === 'error') {
message += `: ${hook.error.message}`
}
if (hook.error) {
logger.error(message, hook.error.stack)
} else {
logger.debug(message)
}
logger.silly('hook.data', hook.data)
logger.silly('hook.params', hook.params)
if (hook.result) {
logger.silly('hook.result', hook.result)
}
}
|