@jsreport/jsreport-core
Advanced tools
Comparing version 4.4.0 to 4.4.1
@@ -7,5 +7,14 @@ const { MESSAGE } = require('triple-beam') | ||
return winston.format((info) => { | ||
const { level, message, ...meta } = info | ||
info[MESSAGE] = `${options.timestamp === true ? `${new Date().toISOString()} - ` : ''}${level}: ${info.userLevel === true ? colors.cyan(message) : message}` | ||
const { level, message, timestamp, ...meta } = info | ||
let logDate | ||
if (timestamp == null) { | ||
logDate = new Date() | ||
info.timestamp = logDate.getTime() | ||
} else { | ||
logDate = new Date(timestamp) | ||
} | ||
info[MESSAGE] = `${options.timestamp === true ? `${logDate.toISOString()} - ` : ''}${level}: ${info.userLevel === true ? colors.cyan(message) : message}` | ||
const metaKeys = Object.keys(meta) | ||
@@ -12,0 +21,0 @@ |
@@ -0,2 +1,4 @@ | ||
const omit = require('lodash.omit') | ||
const winston = require('winston') | ||
const { LEVEL, MESSAGE, SPLAT } = require('triple-beam') | ||
const normalizeMetaFromLogs = require('../shared/normalizeMetaFromLogs') | ||
@@ -6,5 +8,18 @@ | ||
return winston.format((info) => { | ||
const { level, message, ...meta } = info | ||
const newMeta = normalizeMetaFromLogs(level, message, meta) | ||
const { level, message, timestamp: _timestamp, ...meta } = info | ||
const symbolProps = [LEVEL, MESSAGE, SPLAT] | ||
const originalSymbolProps = {} | ||
for (const symbolProp of symbolProps) { | ||
if (info[symbolProp] != null) { | ||
originalSymbolProps[symbolProp] = info[symbolProp] | ||
} | ||
} | ||
const timestamp = _timestamp ?? new Date().getTime() | ||
const targetMeta = omit(meta, symbolProps) | ||
const newMeta = normalizeMetaFromLogs(level, message, timestamp, targetMeta) | ||
if (newMeta != null) { | ||
@@ -14,2 +29,4 @@ return { | ||
message, | ||
timestamp, | ||
...originalSymbolProps, | ||
...newMeta | ||
@@ -16,0 +33,0 @@ } |
@@ -174,2 +174,3 @@ const path = require('path') | ||
} | ||
const transportInstance = new TransportClass(options) | ||
@@ -242,3 +243,2 @@ | ||
winston.format.colorize(), | ||
normalizeMetaLoggerFormat(), | ||
defaultLoggerFormat() | ||
@@ -245,0 +245,0 @@ ) |
const omit = require('lodash.omit') | ||
module.exports = (level, msg, meta) => { | ||
module.exports = (level, msg, timestamp, meta) => { | ||
let result = meta | ||
// detecting if meta is jsreport request object | ||
@@ -11,3 +13,3 @@ if (meta != null && meta.context) { | ||
message: msg, | ||
timestamp: meta.timestamp || new Date().getTime() | ||
timestamp | ||
}) | ||
@@ -27,6 +29,6 @@ | ||
return newMeta | ||
result = newMeta | ||
} | ||
return meta | ||
return result != null && Object.keys(result).length > 0 ? result : null | ||
} |
@@ -38,3 +38,3 @@ const util = require('util') | ||
const meta = normalizeMetaFromLogs(level, log.message, lastArg) | ||
const meta = normalizeMetaFromLogs(level, log.message, log.timestamp, lastArg) | ||
@@ -41,0 +41,0 @@ if (meta != null) { |
{ | ||
"name": "@jsreport/jsreport-core", | ||
"version": "4.4.0", | ||
"version": "4.4.1", | ||
"description": "javascript based business reporting", | ||
@@ -81,3 +81,3 @@ "keywords": [ | ||
"@node-rs/jsonwebtoken": "0.2.0", | ||
"jsdom": "17.0.0", | ||
"jsdom": "24.1.0", | ||
"mocha": "10.1.0", | ||
@@ -84,0 +84,0 @@ "should": "13.2.3", |
@@ -285,2 +285,6 @@ # @jsreport/jsreport-core | ||
### 4.4.1 | ||
- fix timestamp shown in logging | ||
### 4.4.0 | ||
@@ -291,2 +295,3 @@ | ||
- fix component rendering in loop with async work on helpers | ||
- update @jsreport/ses to 1.1.0 | ||
@@ -293,0 +298,0 @@ ### 4.3.1 |
416109
10040
455