@nxtedition/lib 15.0.10 → 15.0.12

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.
Files changed (2) hide show
  1. package/logger.js +11 -9
  2. package/package.json +1 -1
package/logger.js CHANGED
@@ -28,8 +28,7 @@ module.exports.createLogger = function (
28
28
  } else if (!extreme) {
29
29
  stream = pino.destination({ fd: process.stdout.fd ?? 1, sync: true })
30
30
  } else if (!isMainThread) {
31
- // TODO (fix): Async logging?
32
- stream = pino.destination({ fd: 1, sync: true })
31
+ stream = pino.destination({ fd: 1, sync: false })
33
32
  } else {
34
33
  stream = pino.destination({ sync: false, minLength: 4096 })
35
34
  setInterval(() => {
@@ -49,6 +48,12 @@ module.exports.createLogger = function (
49
48
  stream,
50
49
  )
51
50
 
51
+ function flush() {
52
+ stream?.end?.()
53
+ stream?.flush?.()
54
+ stream?.flushSync?.()
55
+ }
56
+
52
57
  let called = false
53
58
  const finalHandler = async (err, evt) => {
54
59
  if (called) {
@@ -62,11 +67,8 @@ module.exports.createLogger = function (
62
67
  }
63
68
  logger.fatal({ err }, evt || 'error caused exit')
64
69
 
65
- process._rawDebug(err.stack)
70
+ flush()
66
71
 
67
- if (stream?.flushSync) {
68
- stream.flushSync()
69
- }
70
72
  process.exit(1)
71
73
  } else {
72
74
  logger.info(`${evt} caught`)
@@ -77,9 +79,9 @@ module.exports.createLogger = function (
77
79
  exitSignal = err.exitSignal || 1
78
80
  logger.warn({ err })
79
81
  }
80
- if (stream?.flushSync) {
81
- stream.flushSync()
82
- }
82
+
83
+ flush()
84
+
83
85
  logger.info({ exitSignal }, 'exit')
84
86
  process.exit(!exitSignal ? 0 : exitSignal)
85
87
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/lib",
3
- "version": "15.0.10",
3
+ "version": "15.0.12",
4
4
  "license": "MIT",
5
5
  "author": "Robert Nagy <robert.nagy@boffins.se>",
6
6
  "files": [