@@ -21,12 +21,17 @@ 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 ) {
25
+ originalConsole . log ( Cluster . workerID ( ) + ' ' . repeat ( currentIndent ) , ...args ) ;
26
+ }
27
+ } ,
28
+ logAlways ( ...args ) {
24
29
if ( process . env . NODE_ENV !== 'test' ) {
25
30
originalConsole . log ( Cluster . workerID ( ) + ' ' . repeat ( currentIndent ) , ...args ) ;
26
31
}
27
32
} ,
28
33
warn ( ...args ) {
29
- if ( process . env . NODE_ENV !== 'test' ) {
34
+ if ( process . env . NODE_ENV !== 'test' && Cluster . verbose ) {
30
35
originalConsole . warn ( Cluster . workerID ( ) + ' ' . repeat ( currentIndent ) , ...args ) ;
31
36
}
32
37
} ,
@@ -36,13 +41,13 @@ const prefixedConsole = {
36
41
}
37
42
} ,
38
43
group ( ...args ) {
39
- if ( process . env . NODE_ENV !== 'test' ) {
44
+ if ( process . env . NODE_ENV !== 'test' && Cluster . verbose ) {
40
45
originalConsole . log ( Cluster . workerID ( ) , chalk . blue . bold ( ...args ) ) ;
41
46
currentIndent += indentAmount ;
42
47
}
43
48
} ,
44
49
groupEnd ( ) {
45
- if ( process . env . NODE_ENV !== 'test' ) {
50
+ if ( process . env . NODE_ENV !== 'test' && Cluster . verbose ) {
46
51
currentIndent -= indentAmount ;
47
52
}
48
53
} ,
@@ -52,6 +57,8 @@ const prefixedConsole = {
52
57
const Cluster = {
53
58
console : prefixedConsole ,
54
59
60
+ verbose : true ,
61
+
55
62
/* Create an access log line */
56
63
logger ( tokens , request , response ) {
57
64
if ( process . env . NODE_ENV !== 'test' ) {
0 commit comments