@treelab/logger-metrics-middleware
Advanced tools
Comparing version 1.0.2-beta to 1.0.4-beta
@@ -17,3 +17,2 @@ "use strict"; | ||
const metrics_1 = require("./metrics"); | ||
const kafka_interface_1 = require("@nestjs/microservices/external/kafka.interface"); | ||
const skipPaths = [ | ||
@@ -61,2 +60,3 @@ '/', | ||
const _message = JSON.parse(_resBody.errors[0].message); | ||
log.err = { message: _message }; | ||
if (_message.status && _message.status >= 500) { | ||
@@ -103,4 +103,6 @@ _statusCode = 500; | ||
catch (err) { | ||
log.level = kafka_interface_1.logLevel.ERROR; | ||
log.err = err; | ||
log = addOptional(ctx.request, ctx); | ||
log.duration = Date.now() - startTime; | ||
log.level = interfaces_1.LogLevel.ERROR; | ||
log.err = { message: err.message, stack: err.stack }; | ||
status = err.status || 500; | ||
@@ -118,12 +120,12 @@ const code = err.code || 'SYSTEM_ERROR'; | ||
finally { | ||
metrics_1.histogram.labels(log.customTag, 'http', log.transaction, status.toString()).observe(log.duration); | ||
if (options.prettyPrint) { | ||
console.log(log); | ||
} | ||
else { | ||
try { | ||
try { | ||
metrics_1.histogram.labels(log.customTag, 'http', log.transaction, status.toString()).observe(log.duration); | ||
if (options.prettyPrint) { | ||
console.log(log); | ||
} | ||
else { | ||
console.log(JSON.stringify(log)); | ||
} | ||
catch (_a) { } | ||
} | ||
catch (_a) { } | ||
} | ||
@@ -146,8 +148,2 @@ }); | ||
}; | ||
if (ctx) { | ||
ctx.req.locals.requestId = log.requestId; | ||
} | ||
else { | ||
req.locals.requestId = log.requestId; | ||
} | ||
let authorization = req.headers['authorization'] || ''; | ||
@@ -154,0 +150,0 @@ if (authorization) { |
{ | ||
"name": "@treelab/logger-metrics-middleware", | ||
"description": "nest js logger-metrics-middleware", | ||
"version": "1.0.2-beta", | ||
"version": "1.0.4-beta", | ||
"author": "simon.shi <simon.shi@treelab.co>", | ||
@@ -6,0 +6,0 @@ "homepage": "https://github.com/treelab/treelab-infra-utils/tree/master/treelab-log-metrics", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
23490
297