@@ -24,10 +24,11 @@ export class BaseLogger<LogObj> {
2424 minLevel : settings ?. minLevel ?? 0 ,
2525 argumentsArrayName : settings ?. argumentsArrayName ,
2626 prettyLogTemplate :
27- settings ?. prettyLogTemplate ?? "{{yyyy}}.{{mm}}.{{dd}} {{hh}}:{{MM}}:{{ss}}:{{ms}}\t{{logLevelName}}\t[{{filePathWithLine}}{{name}}]\t " ,
27+ settings ?. prettyLogTemplate ?? "{{yyyy}}.{{mm}}.{{dd}} {{hh}}:{{MM}}:{{ss}}:{{ms}}\t{{logLevelName}}\t[{{filePathWithLine}}]\t {{name}}" ,
2828 prettyErrorTemplate : settings ?. prettyErrorTemplate ?? "\n{{errorName}} {{errorMessage}}\nerror stack:\n{{errorStack}}" ,
2929 prettyErrorStackTemplate : settings ?. prettyErrorTemplate ?? " • {{fileName}}\t{{method}}\n\t{{filePathWithLine}}" ,
3030 prettyErrorParentNamesSeparator : settings ?. prettyErrorParentNamesSeparator ?? ":" ,
31+ prettyErrorLoggerNameDelimiter : settings ?. prettyErrorLoggerNameDelimiter ?? "\t" ,
3132 stylePrettyLogs : settings ?. stylePrettyLogs ?? true ,
3233 prettyLogStyles : settings ?. prettyLogStyles ?? {
3334 logLevelName : {
@@ -42,7 +43,7 @@ export class BaseLogger<LogObj> {
4243 } ,
4344 dateIsoStr : "white" ,
4445 filePathWithLine : "white" ,
45- name : "white" ,
46+ name : [ "white" , "bold" ] ,
4647 errorName : [ "bold" , "bgRedBright" , "whiteBright" ] ,
4748 fileName : [ "yellow" ] ,
4849 } ,
@@ -89,8 +90,8 @@ export class BaseLogger<LogObj> {
8990 this . settings . overwrite ?. mask != null
9091 ? this . settings . overwrite ?. mask ( logArgs )
9192 : this . settings . maskValuesOfKeys != null && this . settings . maskValuesOfKeys . length > 0
92- ? this . _mask ( logArgs )
93- : logArgs ;
93+ ? this . _mask ( logArgs )
94+ : logArgs ;
9495 // execute default LogObj functions for every log (e.g. requestId)
9596 const thisLogObj : LogObj | undefined = this . logObj != null ? this . _recursiveCloneAndExecuteFunctions ( this . logObj ) : undefined ;
9697 const logObj : LogObj =
@@ -124,8 +125,8 @@ export class BaseLogger<LogObj> {
124125 this . settings . overwrite ?. transportJSON != null
125126 ? this . settings . overwrite ?. transportJSON ( logObjWithMeta )
126127 : this . settings . type !== "hidden"
127- ? transportJSON ( logObjWithMeta )
128- : undefined ;
128+ ? transportJSON ( logObjWithMeta )
129+ : undefined ;
129130 }
130131
131132 if ( this . settings . attachedTransports != null && this . settings . attachedTransports . length > 0 ) {
@@ -160,8 +161,8 @@ export class BaseLogger<LogObj> {
160161 this . settings ?. parentNames != null && this . settings ?. name != null
161162 ? [ ...this . settings . parentNames , this . settings . name ]
162163 : this . settings ?. name != null
163- ? [ this . settings . name ]
164- : undefined ,
164+ ? [ this . settings . name ]
165+ : undefined ,
165166 // merge all prefixes instead of overwriting them
166167 prefix : [ ...this . settings . prefix , ...( settings ?. prefix ?? [ ] ) ] ,
167168 } ;
@@ -215,15 +216,15 @@ export class BaseLogger<LogObj> {
215216 return Array . isArray ( source )
216217 ? source . map ( ( item ) => this . _recursiveCloneAndExecuteFunctions ( item ) )
217218 : source instanceof Date
218- ? new Date ( source . getTime ( ) )
219- : source && typeof source === "object"
220- ? Object . getOwnPropertyNames ( source ) . reduce ( ( o , prop ) => {
221- Object . defineProperty ( o , prop , Object . getOwnPropertyDescriptor ( source , prop ) ! ) ;
222- // execute functions or clone
223- o [ prop ] = typeof source [ prop ] === "function" ? source [ prop ] ( ) : this . _recursiveCloneAndExecuteFunctions ( ( source as { [ key : string ] : unknown } ) [ prop ] ) ;
224- return o ;
225- } , Object . create ( Object . getPrototypeOf ( source ) ) )
226- : ( source as T ) ;
219+ ? new Date ( source . getTime ( ) )
220+ : source && typeof source === "object"
221+ ? Object . getOwnPropertyNames ( source ) . reduce ( ( o , prop ) => {
222+ Object . defineProperty ( o , prop , Object . getOwnPropertyDescriptor ( source , prop ) ! ) ;
223+ // execute functions or clone
224+ o [ prop ] = typeof source [ prop ] === "function" ? source [ prop ] ( ) : this . _recursiveCloneAndExecuteFunctions ( ( source as { [ key : string ] : unknown } ) [ prop ] ) ;
225+ return o ;
226+ } , Object . create ( Object . getPrototypeOf ( source ) ) )
227+ : ( source as T ) ;
227228 }
228229
229230 private _toLogObj ( args : unknown [ ] , clonedLogObj : LogObj = { } as LogObj ) : LogObj {
@@ -289,7 +290,8 @@ export class BaseLogger<LogObj> {
289290 // name
290291 let parentNamesString = this . settings . parentNames ?. join ( this . settings . prettyErrorParentNamesSeparator ) ;
291292 parentNamesString = parentNamesString != null && logObjMeta ?. name != null ? parentNamesString + this . settings . prettyErrorParentNamesSeparator : undefined ;
292- placeholderValues [ "name" ] = logObjMeta ?. name != null || parentNamesString != null ? ( parentNamesString ?? "" ) + logObjMeta ?. name ?? "" : "" ;
293+ const nameStr = logObjMeta ?. name != null || parentNamesString != null ? ( parentNamesString ?? "" ) + logObjMeta ?. name ?? "" : "" ;
294+ placeholderValues [ "name" ] = nameStr . length > 0 ? nameStr + this . settings . prettyErrorLoggerNameDelimiter : "" ;
293295
294296 return formatTemplate ( this . settings , template , placeholderValues ) ;
295297 }
0 commit comments