File tree 2 files changed +10
-1
lines changed 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import { LogItem } from './log';
6
6
import cloneDeep from 'lodash.clonedeep' ;
7
7
import merge from 'lodash.merge' ;
8
8
import { ConfigServiceInterface , EnvironmentVariablesService } from './config' ;
9
+ import { LogJsonIndent } from './types' ;
9
10
import type {
10
11
ClassThatLogs ,
11
12
Environment ,
@@ -569,7 +570,10 @@ class Logger extends Utility implements ClassThatLogs {
569
570
570
571
const consoleMethod = logLevel . toLowerCase ( ) as keyof ClassThatLogs ;
571
572
572
- this . console [ consoleMethod ] ( JSON . stringify ( log . getAttributes ( ) , this . removeCircularDependencies ( ) ) ) ;
573
+ const isDevMode = this . getEnvVarsService ( ) . getDevMode ( ) ;
574
+ const INDENTATION : LogJsonIndent = isDevMode ? LogJsonIndent . PRETTY : LogJsonIndent . COMPACT ;
575
+
576
+ this . console [ consoleMethod ] ( JSON . stringify ( log . getAttributes ( ) , this . removeCircularDependencies ( ) , INDENTATION ) ) ;
573
577
}
574
578
575
579
/**
Original file line number Diff line number Diff line change @@ -74,3 +74,8 @@ export {
74
74
ConstructorOptions ,
75
75
HandlerOptions
76
76
} ;
77
+
78
+ export const enum LogJsonIndent {
79
+ PRETTY = 4 ,
80
+ COMPACT = 0 ,
81
+ }
You can’t perform that action at this time.
0 commit comments