File tree 2 files changed +32
-1
lines changed
2 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -1451,6 +1451,14 @@ class Logger extends Utility implements LoggerInterface {
1451
1451
)
1452
1452
) ;
1453
1453
}
1454
+ const AlcLogLevel =
1455
+ this . getEnvVarsService ( ) . getAwsLogLevel ( ) as keyof typeof LogLevelThreshold ;
1456
+
1457
+ if ( LogLevelThreshold [ AlcLogLevel ] > this . #bufferConfig. bufferAtVerbosity ) {
1458
+ this . #warnOnce(
1459
+ 'Advanced Loggging Controls (ALC) Log Level is less verbose than Log Buffering Log Level. Some logs might be missing.'
1460
+ ) ;
1461
+ }
1454
1462
1455
1463
this . #buffer?. delete ( traceId ) ;
1456
1464
}
Original file line number Diff line number Diff line change @@ -92,7 +92,7 @@ describe('Buffer logs', () => {
92
92
) ;
93
93
} ) ;
94
94
95
- it ( 'outputs a warning when the Advanced Logging Configuration Log Level is higher than the Log Buffering Log Level' , ( ) => {
95
+ it ( 'outputs a warning when the Advanced Logging Configuration Log Level is less verbose than the Log Buffering Log Level' , ( ) => {
96
96
// Assemble
97
97
process . env . AWS_LAMBDA_LOG_LEVEL = 'INFO' ;
98
98
const logger = new Logger ( {
@@ -114,6 +114,29 @@ describe('Buffer logs', () => {
114
114
) ;
115
115
} ) ;
116
116
117
+ it ( 'When the buffer is flushed it outputs a warning if the Advanced Logging Configuration Log Level is less verbose than the Log Buffering Log Level' , ( ) => {
118
+ // Assemble
119
+ process . env . AWS_LAMBDA_LOG_LEVEL = 'INFO' ;
120
+ const logger = new Logger ( {
121
+ logLevel : LogLevel . DEBUG ,
122
+ logBufferOptions : { enabled : true , bufferAtVerbosity : 'DEBUG' } ,
123
+ } ) ;
124
+
125
+ // Act
126
+ logger . debug ( 'This is a debug' ) ;
127
+ logger . flushBuffer ( ) ;
128
+
129
+ // Assess
130
+ expect ( console . warn ) . toHaveLogged (
131
+ expect . objectContaining ( {
132
+ message : expect . stringContaining (
133
+ 'Advanced Loggging Controls (ALC) Log Level is less verbose than Log Buffering Log Level. Some logs might be missing.'
134
+ ) ,
135
+ level : LogLevel . WARN ,
136
+ } )
137
+ ) ;
138
+ } ) ;
139
+
117
140
it ( 'outputs a warning when there is an error buffering the log' , ( ) => {
118
141
// Prepare
119
142
const logger = new Logger ( { logBufferOptions : { maxBytes : 100 } } ) ;
You can’t perform that action at this time.
0 commit comments