akos-logger-promotion
Advanced tools
Comparing version 0.0.3 to 0.0.4
@@ -13,9 +13,6 @@ | ||
let fields = null; | ||
const cookie = ctx.get('Cookie'); | ||
const start = moment(); | ||
const requestId = ctx.requestId || uuid.v4(); | ||
const requestId = ctx.app.requestId || uuid.v4(); | ||
const log = ctx.logger || console.log; | ||
let msg = `enter:${ctx.ip}requestId_${requestId}-${chalk.magenta(ctx.method)} "${ctx.path}" from ${ctx.ip}`; | ||
if (cookie && options.cookie) | ||
msg += ` with cookie "${cookie}"`; | ||
@@ -52,7 +49,7 @@ if (ctx.query && !_.isEmpty(ctx.query)) | ||
if (ctx.errors && ctx.errors.length) | ||
log.warn(`[akos-logger-promotion] %s`, `Request validation errros: ${ctx.errors}`); | ||
log.warn('[akos-logger-promotion] %s', `Request validation errros: ${ctx.errors}`); | ||
if (ctx.type === 'application/json') | ||
log.info(`[akos-logger-promotion] %s`, `leave: ${ctx.ip} requestId_ ${requestId}-${ctx.method} ${ctx.path} complete ${chalk.bold.white.bgMagenta(ctx.status)} at ${chalk.bold.cyan(moment() - start)}ms with body ${body}`); | ||
log.info('[akos-logger-promotion] %s', `leave: ${ctx.ip} requestId_ ${requestId}-${ctx.method} ${ctx.path} complete ${chalk.bold.white.bgMagenta(ctx.status)} at ${chalk.bold.cyan(moment() - start)}ms with body ${body}`); | ||
else | ||
log.info(`[akos-logger-promotion] %s`, `leave res: ${ctx.ip} requestId_${requestId}-${ctx.method} ${ctx.path} complete ${chalk.bold.white.bgMagenta(ctx.status)} at ${chalk.bold.cyan(moment() - start)}ms`); | ||
log.info('[akos-logger-promotion] %s', `leave res: ${ctx.ip} requestId_${requestId}-${ctx.method} ${ctx.path} complete ${chalk.bold.white.bgMagenta(ctx.status)} at ${chalk.bold.cyan(moment() - start)}ms`); | ||
}; |
{ | ||
"name": "akos-logger-promotion", | ||
"description": "a logger promotion for akos", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"main": "main.js", | ||
@@ -6,0 +6,0 @@ "directories": { |
13990
329