@trojs/logger 0.5.12 → 0.5.14

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@trojs/logger",
3
3
  "description": "Winston logger for TroJS",
4
- "version": "0.5.12",
4
+ "version": "0.5.14",
5
5
  "author": {
6
6
  "name": "Pieter Wigboldus",
7
7
  "url": "https://trojs.org/"
@@ -6,6 +6,15 @@ export default ({ winston, logger }) => {
6
6
  const jsonFormatter = winston.format.combine(
7
7
  winston.format.errors({ stack: logger?.debug ?? false }),
8
8
  winston.format((info) => {
9
+ if (!info.message) {
10
+ info.message = info instanceof Error
11
+ ? info.toString()
12
+ : JSON.stringify(info)
13
+ } else if (info.message instanceof Error) {
14
+ info.message = info.message.toString()
15
+ } else if (typeof info.message !== 'string') {
16
+ info.message = JSON.stringify(info.message)
17
+ }
9
18
  if (logger?.debug && info.stack) {
10
19
  info.stacktrace = info.stack
11
20
  }
@@ -24,6 +33,12 @@ export default ({ winston, logger }) => {
24
33
 
25
34
  const defaultFormatter = winston.format.combine(
26
35
  winston.format.errors({ stack: logger?.debug ?? false }),
36
+ winston.format((info) => {
37
+ if (!info.message && info instanceof Error) {
38
+ info.message = info.toString()
39
+ }
40
+ return info
41
+ })(),
27
42
  simpleLoggerWithStack
28
43
  )
29
44