@unchainedshop/logger 4.8.21 → 4.8.22

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.
@@ -1,5 +1,5 @@
1
1
  import { inspect } from 'node:util';
2
- import { stringify } from 'safe-stable-stringify';
2
+ import { safeStringify } from "./safe-stringify.js";
3
3
  import { LogLevel } from "./logger.types.js";
4
4
  const regexCache = new Map();
5
5
  const debugPatternCache = new Map();
@@ -87,12 +87,6 @@ const formatTimestamp = () => {
87
87
  const seconds = now.getSeconds().toString().padStart(2, '0');
88
88
  return `${hours}:${minutes}:${seconds}`;
89
89
  };
90
- const bigintReplacer = (_key, value) => {
91
- if (typeof value === 'bigint') {
92
- return value.toString();
93
- }
94
- return value;
95
- };
96
90
  export const resetLoggerInitialization = () => {
97
91
  regexCache.clear();
98
92
  debugPatternCache.clear();
@@ -130,7 +124,7 @@ export const createLogger = (moduleName) => {
130
124
  logObject[key] = args[0][key];
131
125
  }
132
126
  }
133
- console.log(stringify(logObject, bigintReplacer));
127
+ console.log(safeStringify(logObject));
134
128
  }
135
129
  else {
136
130
  const timestamp = formatTimestamp();
@@ -1,3 +1,4 @@
1
1
  export * from './createLogger.ts';
2
+ export * from './safe-stringify.ts';
2
3
  export * from './logger.types.ts';
3
4
  export * from './log.ts';
@@ -1,3 +1,4 @@
1
1
  export * from "./createLogger.js";
2
+ export * from "./safe-stringify.js";
2
3
  export * from "./logger.types.js";
3
4
  export * from "./log.js";
@@ -0,0 +1,2 @@
1
+ export declare function safeStringify(value: any, replacer?: ((this: any, key: string, value: any) => any) | null, space?: string | number): string | undefined;
2
+ export default safeStringify;
@@ -0,0 +1,19 @@
1
+ export function safeStringify(value, replacer, space) {
2
+ const ancestors = [];
3
+ return JSON.stringify(value, function (key, val) {
4
+ const replaced = replacer ? replacer.call(this, key, val) : val;
5
+ if (typeof replaced === 'bigint')
6
+ return replaced.toString();
7
+ if (typeof replaced !== 'object' || replaced === null)
8
+ return replaced;
9
+ if (replaced instanceof BigInt)
10
+ return String(replaced);
11
+ while (ancestors.length > 0 && ancestors[ancestors.length - 1] !== this)
12
+ ancestors.pop();
13
+ if (ancestors.includes(replaced))
14
+ return '[Circular]';
15
+ ancestors.push(replaced);
16
+ return replaced;
17
+ }, space);
18
+ }
19
+ export default safeStringify;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unchainedshop/logger",
3
3
  "description": "High-performance logging package for the Unchained Engine",
4
- "version": "4.8.21",
4
+ "version": "4.8.22",
5
5
  "main": "lib/logger-index.js",
6
6
  "types": "lib/logger-index.d.ts",
7
7
  "type": "module",
@@ -36,9 +36,6 @@
36
36
  "url": "https://github.com/unchainedshop/unchained/issues"
37
37
  },
38
38
  "homepage": "https://github.com/unchainedshop/unchained#readme",
39
- "dependencies": {
40
- "safe-stable-stringify": "^2.5.0"
41
- },
42
39
  "devDependencies": {
43
40
  "@types/node": "^26.2.0",
44
41
  "typescript": "^5.8.3"