use inspect instead of json.serialize for raw objects to prevent errors with circular objects

This commit is contained in:
einhornimmond 2025-06-18 09:40:46 +02:00
parent bedafc4592
commit d50c2fd276

View File

@ -1,6 +1,7 @@
import { Level, LoggingEvent } from 'log4js'
import colors from 'yoctocolors-cjs'
import { ColoredContextLayoutConfig, LogLevel } from './types'
import { inspect } from 'node:util'
function colorize(str: string, level: Level): string {
switch (level.colour) {
@ -33,7 +34,7 @@ function composeDataString(data: (string | Object)[]): string {
.map((d) => {
// if it is a object and his toString function return only garbage
if (typeof d === 'object' && d.toString() === '[object Object]') {
return JSON.stringify(d)
return inspect(d, )
}
if (d) {
return d.toString()