Commit 3fa89635 authored by Eirik Alvær's avatar Eirik Alvær
Browse files

Log simplified object to console when using fluent.

parent 925e742f
Pipeline #49061 passed with stage
in 21 seconds
{
"name": "@nsd/log-schema-node",
"version": "3.6.2",
"version": "4.0.0",
"main": "lib/index.js",
"types": "lib/index",
"scripts": {
......
......@@ -199,6 +199,22 @@ function getLogData(input: LogInput): LogSchema {
return res as LogSchema;
}
function simplifyLogObject(obj: LogSchema) {
const res = _.cloneDeep(obj);
delete res.loggerName;
delete res.serviceName;
delete res.schemaVersion;
delete res.serviceStack;
delete res.xRequestId;
delete res.host;
delete res.port;
delete res.url;
delete res.process;
delete res.thread;
delete res.port;
return res;
}
function log(levelName: LogSchema["levelName"], input: LogInput) {
if (!shouldLog(levelName)) {
return;
......@@ -208,9 +224,14 @@ function log(levelName: LogSchema["levelName"], input: LogInput) {
}
try {
const fullLogInput = _.merge({ levelName }, input);
const data = getLogData(fullLogInput);
const str = stringify(data, Number.MAX_SAFE_INTEGER);
console.log(str);
const data = getLogData(fullLogInput);
if (useFluent) {
const str = stringify(simplifyLogObject(data), Number.MAX_SAFE_INTEGER);
console.log(str);
} else {
const str = stringify(data, Number.MAX_SAFE_INTEGER);
console.log(str);
}
dataLoggedEvent(data);
if (isDev()) {
JsonSchema.validate(data, schema, { throwError: true });
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment