@sentio/runtime 2.48.1-rc.1 → 2.48.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentio/runtime",
3
- "version": "2.48.1-rc.1",
3
+ "version": "2.48.1",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "exports": {
package/src/logger.ts CHANGED
@@ -1,12 +1,29 @@
1
1
  import { createLogger, format, transports } from 'winston'
2
2
 
3
+ function stringify(obj: any) {
4
+ let cache: any[] = []
5
+ const str = JSON.stringify(obj, function (key, value) {
6
+ if (typeof value === 'object' && value !== null) {
7
+ if (cache.indexOf(value) !== -1) {
8
+ // Circular reference found, discard key
9
+ return
10
+ }
11
+ // Store value in our collection
12
+ cache.push(value)
13
+ }
14
+ return value
15
+ })
16
+ cache = []
17
+ return str
18
+ }
19
+
3
20
  export function setupLogger(json: boolean, enableDebug: boolean) {
4
21
  const utilFormatter = {
5
22
  transform: (info: any) => {
6
23
  const stringRes = []
7
24
 
8
25
  if (typeof info.message === 'object') {
9
- stringRes.push(JSON.stringify(info.message))
26
+ stringRes.push(stringify(info.message))
10
27
  } else {
11
28
  stringRes.push(info.message)
12
29
  }
@@ -16,7 +33,7 @@ export function setupLogger(json: boolean, enableDebug: boolean) {
16
33
  for (const idx in args) {
17
34
  const arg = args[idx]
18
35
  if (typeof arg === 'object') {
19
- stringRes.push(JSON.stringify(arg))
36
+ stringRes.push(stringify(arg))
20
37
  } else {
21
38
  stringRes.push(arg)
22
39
  }