@jsreport/jsreport-core 4.4.0 → 4.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -282,11 +282,16 @@ jsreport.documentStore.collection('templates')
282
282
 
283
283
  ## Changelog
284
284
 
285
+ ### 4.4.1
286
+
287
+ - fix timestamp shown in logging
288
+
285
289
  ### 4.4.0
286
290
 
287
291
  - trigger async report using header to avoid allocating worker
288
292
  - fix require('..') and require('.') in sandbox
289
293
  - fix component rendering in loop with async work on helpers
294
+ - update @jsreport/ses to 1.1.0
290
295
 
291
296
  ### 4.3.1
292
297
 
@@ -4,8 +4,17 @@ const winston = require('winston')
4
4
 
5
5
  module.exports = (options = {}) => {
6
6
  return winston.format((info) => {
7
- const { level, message, ...meta } = info
8
- info[MESSAGE] = `${options.timestamp === true ? `${new Date().toISOString()} - ` : ''}${level}: ${info.userLevel === true ? colors.cyan(message) : message}`
7
+ const { level, message, timestamp, ...meta } = info
8
+ let logDate
9
+
10
+ if (timestamp == null) {
11
+ logDate = new Date()
12
+ info.timestamp = logDate.getTime()
13
+ } else {
14
+ logDate = new Date(timestamp)
15
+ }
16
+
17
+ info[MESSAGE] = `${options.timestamp === true ? `${logDate.toISOString()} - ` : ''}${level}: ${info.userLevel === true ? colors.cyan(message) : message}`
9
18
 
10
19
  const metaKeys = Object.keys(meta)
11
20
 
@@ -1,15 +1,32 @@
1
+ const omit = require('lodash.omit')
1
2
  const winston = require('winston')
3
+ const { LEVEL, MESSAGE, SPLAT } = require('triple-beam')
2
4
  const normalizeMetaFromLogs = require('../shared/normalizeMetaFromLogs')
3
5
 
4
6
  module.exports = () => {
5
7
  return winston.format((info) => {
6
- const { level, message, ...meta } = info
7
- const newMeta = normalizeMetaFromLogs(level, message, meta)
8
+ const { level, message, timestamp: _timestamp, ...meta } = info
9
+
10
+ const symbolProps = [LEVEL, MESSAGE, SPLAT]
11
+ const originalSymbolProps = {}
12
+
13
+ for (const symbolProp of symbolProps) {
14
+ if (info[symbolProp] != null) {
15
+ originalSymbolProps[symbolProp] = info[symbolProp]
16
+ }
17
+ }
18
+
19
+ const timestamp = _timestamp ?? new Date().getTime()
20
+
21
+ const targetMeta = omit(meta, symbolProps)
22
+ const newMeta = normalizeMetaFromLogs(level, message, timestamp, targetMeta)
8
23
 
9
24
  if (newMeta != null) {
10
25
  return {
11
26
  level,
12
27
  message,
28
+ timestamp,
29
+ ...originalSymbolProps,
13
30
  ...newMeta
14
31
  }
15
32
  }
@@ -171,6 +171,7 @@ function configureLogger (logger, _transports) {
171
171
  if (options.silent) {
172
172
  continue
173
173
  }
174
+
174
175
  const transportInstance = new TransportClass(options)
175
176
 
176
177
  const existingTransport = logger.transports.find((t) => t.name === transportInstance.name)
@@ -238,7 +239,6 @@ class DebugTransport extends Transport {
238
239
 
239
240
  this.format = options.format || winston.format.combine(
240
241
  winston.format.colorize(),
241
- normalizeMetaLoggerFormat(),
242
242
  defaultLoggerFormat()
243
243
  )
244
244
 
@@ -1,6 +1,8 @@
1
1
  const omit = require('lodash.omit')
2
2
 
3
- module.exports = (level, msg, meta) => {
3
+ module.exports = (level, msg, timestamp, meta) => {
4
+ let result = meta
5
+
4
6
  // detecting if meta is jsreport request object
5
7
  if (meta != null && meta.context) {
6
8
  meta.context.logs = meta.context.logs || []
@@ -8,7 +10,7 @@ module.exports = (level, msg, meta) => {
8
10
  meta.context.logs.push({
9
11
  level: level,
10
12
  message: msg,
11
- timestamp: meta.timestamp || new Date().getTime()
13
+ timestamp
12
14
  })
13
15
 
14
16
  // TODO adding cancel looks bad, its before script is adding req.cancel()
@@ -23,8 +25,8 @@ module.exports = (level, msg, meta) => {
23
25
  newMeta.id = meta.context.id
24
26
  }
25
27
 
26
- return newMeta
28
+ result = newMeta
27
29
  }
28
30
 
29
- return meta
31
+ return result != null && Object.keys(result).length > 0 ? result : null
30
32
  }
@@ -35,7 +35,7 @@ function logFn (level, profiler, ...args) {
35
35
  message: util.format.apply(util, msgArgs)
36
36
  }
37
37
 
38
- const meta = normalizeMetaFromLogs(level, log.message, lastArg)
38
+ const meta = normalizeMetaFromLogs(level, log.message, log.timestamp, lastArg)
39
39
 
40
40
  if (meta != null) {
41
41
  log.meta = meta
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsreport/jsreport-core",
3
- "version": "4.4.0",
3
+ "version": "4.4.1",
4
4
  "description": "javascript based business reporting",
5
5
  "keywords": [
6
6
  "report",
@@ -78,7 +78,7 @@
78
78
  },
79
79
  "devDependencies": {
80
80
  "@node-rs/jsonwebtoken": "0.2.0",
81
- "jsdom": "17.0.0",
81
+ "jsdom": "24.1.0",
82
82
  "mocha": "10.1.0",
83
83
  "should": "13.2.3",
84
84
  "standard": "16.0.4",