@batolye/bdk-core
Version:
Module to provide core utilities for BulusAtolyesi applications and services
28 lines (22 loc) • 665 B
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.log = log;
// A hook that logs service method before, after and error
function log(hook) {
let message = `${hook.type}: ${hook.path} - Method: ${hook.method}`;
if (hook.type === "error") {
message += `: ${hook.error.message}`;
}
if (hook.error) {
hook.app.core_logger.error(message, hook.error.stack);
} else {
hook.app.core_logger.debug(message);
}
hook.app.core_logger.silly("hook.data", hook.data);
hook.app.core_logger.silly("hook.params", hook.params);
if (hook.result) {
hook.app.core_logger.silly("hook.result", hook.result);
}
}
;