@@ -49,29 +49,28 @@ class ACL {
49
49
*/
50
50
constructor ( config = { } ) {
51
51
// Logging level settings
52
- this . logLevel = config . logLevel || 1 ;
52
+ this . logLevel = typeof config . logLevel === "number" ? config . logLevel : 1 ;
53
53
54
54
// File logging options
55
55
this . outputFilename = config . outputFilename || null ;
56
- this . outputFilenameLogLevel =
57
- config . outputFilenameLogLevel || this . logLevel ;
56
+ this . outputFilenameLogLevel = config . outputFilenameLogLevel ?? 1 ;
58
57
59
58
// Include timestamps in log messages
60
59
this . includeTimestamps = config . includeTimestamps !== false ;
61
60
62
61
// Memory usage settings
63
62
this . includeMemoryUsage = config . includeMemoryUsage || false ;
64
- this . memoryCheckFrequency = config . memoryCheckFrequency || 10 ;
65
- this . memoryDisplayMode = config . memoryDisplayMode || 1 ;
63
+ this . memoryCheckFrequency = config . memoryCheckFrequency ?? 10 ; // Accept 0 values
64
+ this . memoryDisplayMode = config . memoryDisplayMode ?? 1 ; // Accept 0 values
66
65
67
66
// Caller info settings
68
67
this . includeCallerInfo = config . includeCallerInfo || false ;
69
- this . callerInfoLevel = config . callerInfoLevel || 2 ; // Default to warn and above
70
- this . callerInfoDisplayMode = config . callerInfoDisplayMode || 1 ;
68
+ this . callerInfoLevel = config . callerInfoLevel ?? 2 ; // Accept 0 values
69
+ this . callerInfoDisplayMode = config . callerInfoDisplayMode ?? 1 ; // Accept 0 values
71
70
72
71
// Inline caller info settings
73
72
this . includeInlineCallerInfo = ! ! config . includeInlineCallerInfo ;
74
- this . inlineCallerInfoLevel = config . inlineCallerInfoLevel || 1 ;
73
+ this . inlineCallerInfoLevel = config . inlineCallerInfoLevel ?? 1 ; // Accept 0 values
75
74
76
75
// Include stack trace in error and fatal messages
77
76
this . includeStackTrace = ! ! config . includeStackTrace ;
@@ -235,14 +234,17 @@ class ACL {
235
234
* @returns {boolean } - Whether to log to console.
236
235
*/
237
236
shouldLogToConsole ( condition , level ) {
237
+ console . log ( this . logLevel , condition , level ) ;
238
238
if (
239
239
this . logLevel === 0 ||
240
240
( typeof condition === "boolean" && ! condition ) ||
241
241
( this . logLevel === 2 && level < 2 ) ||
242
242
( this . logLevel === 3 && level < 3 )
243
243
) {
244
+ console . log ( "shouldLogToConsole" , "false" ) ;
244
245
return false ;
245
246
}
247
+ console . log ( "shouldLogToConsole" , "true" ) ;
246
248
return true ;
247
249
}
248
250
0 commit comments