Add command-line flag to enable logs in tests #96
Labels
good first issue
Good for newcomers
help wanted
Contributions are welcome
tests
Improvements or additions to tests
Currently, logging to console is disabled in tests. This is achieved by to measures:
log_test.go
definesdefaultLogLevel LogLevel = LogError
; all tests that temporary enable logs, restore log level to this value; this level prevents all log messages except errorsmain_test.go
invokeslog.SetOutput(ioutil.Discard)
; all tests that temporary redirect logs, restore log output toioutil.Discard
; this prevents logs to be written to consoleHowever, for debugging, it may be useful to enable console logging.
We can do the following:
defaultLogLevel
a variable (default is stillLogError
)defaultLogOutput
(default isioutil.Discard
)defaultLogLevel
is set toLogDebug
, anddefaultLogOutput
to consoledefaultLogLevel
anddefaultLogOutput
log.SetOutput(ioutil.Discard)
, and instead uselog.SetOutput(defaultLogOutput)
Also, I think it makes sense to rename
defaultLogLevel
anddefaultLogOutput
todefaultTestLogLevel
anddefaultTestLogOutput
.The text was updated successfully, but these errors were encountered: