File tree Expand file tree Collapse file tree 3 files changed +18
-1
lines changed
Expand file tree Collapse file tree 3 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,12 @@ class Logger {
4040 this . command = '' ;
4141 // Last line
4242 this . lastCommand = '' ;
43+
44+ // set level from env
45+ const level = process . env . LOGGER ;
46+ if ( this . isLevelValid ( level ) ) {
47+ this . level = level ;
48+ }
4349 }
4450
4551 setLevel ( level ) {
Original file line number Diff line number Diff line change 44 "description" : " More powerful logger for NodeJs" ,
55 "main" : " index.js" ,
66 "scripts" : {
7- "test" : " node test.js"
7+ "test" : " node test.js && LOGGER=info node test2.js "
88 },
99 "repository" : {
1010 "type" : " git" ,
Original file line number Diff line number Diff line change 1+ const logger = require ( './index' ) ;
2+
3+ // $ LOGGER=info node test2.js
4+ logger . log ( '****************************************' ) ;
5+ logger . log ( '*** Test Environment Variable LOGGER ***' ) ;
6+ logger . log ( '****************************************' ) ;
7+ logger . log ( "LOGGER=info, debug level will not show" ) ;
8+ logger . error ( 'error show' ) ;
9+ logger . warn ( 'warn show' ) ;
10+ logger . info ( 'info show' ) ;
11+ logger . debug ( 'debug will not show' ) ;
You can’t perform that action at this time.
0 commit comments