@@ -21,7 +21,7 @@ const originalConsole = console;
21
21
/* Prefixing native console methods with worker ID */
22
22
const prefixedConsole = {
23
23
log ( ...args ) {
24
- if ( process . env . NODE_ENV !== 'test' && Cluster . verbose ) {
24
+ if ( process . env . NODE_ENV !== 'test' && Cluster . isVerbose ( ) ) {
25
25
originalConsole . log ( Cluster . workerID ( ) + ' ' . repeat ( currentIndent ) , ...args ) ;
26
26
}
27
27
} ,
@@ -31,7 +31,7 @@ const prefixedConsole = {
31
31
}
32
32
} ,
33
33
warn ( ...args ) {
34
- if ( process . env . NODE_ENV !== 'test' && Cluster . verbose ) {
34
+ if ( process . env . NODE_ENV !== 'test' && Cluster . isVerbose ( ) ) {
35
35
originalConsole . warn ( Cluster . workerID ( ) + ' ' . repeat ( currentIndent ) , ...args ) ;
36
36
}
37
37
} ,
@@ -41,13 +41,13 @@ const prefixedConsole = {
41
41
}
42
42
} ,
43
43
group ( ...args ) {
44
- if ( process . env . NODE_ENV !== 'test' && Cluster . verbose ) {
44
+ if ( process . env . NODE_ENV !== 'test' && Cluster . isVerbose ( ) ) {
45
45
originalConsole . log ( Cluster . workerID ( ) , chalk . blue . bold ( ...args ) ) ;
46
46
currentIndent += indentAmount ;
47
47
}
48
48
} ,
49
49
groupEnd ( ) {
50
- if ( process . env . NODE_ENV !== 'test' && Cluster . verbose ) {
50
+ if ( process . env . NODE_ENV !== 'test' && Cluster . isVerbose ( ) ) {
51
51
currentIndent -= indentAmount ;
52
52
}
53
53
} ,
@@ -57,8 +57,6 @@ const prefixedConsole = {
57
57
const Cluster = {
58
58
console : prefixedConsole ,
59
59
60
- verbose : true ,
61
-
62
60
/* Create an access log line */
63
61
logger ( tokens , request , response ) {
64
62
if ( process . env . NODE_ENV !== 'test' ) {
@@ -84,6 +82,11 @@ const Cluster = {
84
82
console . log ( `${ chalk . magenta ( `Worker ${ cluster . worker ? cluster . worker . id : 0 } (${ pid } )` ) } now listening on port ${ port } ` ) ;
85
83
}
86
84
} ,
85
+
86
+ /* Return whether verbose logging is on or off */
87
+ isVerbose ( ) {
88
+ return process . env . VERBOSE_LOGGING !== 'false' ;
89
+ } ,
87
90
} ;
88
91
89
92
export { prefixedConsole as console } ;
0 commit comments