Conversation
| ipfsLogLevel, _ := logging.LevelFromString(os.Getenv("IPFS_LOGGING")) // IPFS_LOGGING is deprecated | ||
| goLogLevel, _ := logging.LevelFromString(os.Getenv("GOLOG_LOG_LEVEL")) | ||
|
|
||
| if debug || goLogLevel == logging.LevelDebug || ipfsLogLevel == logging.LevelDebug { |
There was a problem hiding this comment.
based on the documentation at https://github.com/ipfs/go-log#usage I think this should do what we want (support non-deprecated env var, still allow old one..)
This change also corrects functionality to where export GOLOG_LOG_LEVEL="debug,subsystem=info" will actually enable debug logging, instead of potentially not.
AFAIK, "debug,system=info" == "debug" would have previously returned false. Idk if that was intended or not.
There was a problem hiding this comment.
Hm... this only works for simple "debug", but that was also true before, so not a blocker for this PR.
(The LevelFromString is backed by https://github.com/uber-go/zap/blob/fcf8ee58669e358bbd6460bef5c2ee7a53c0803a/zapcore/level.go#L180 which is matching string exactly and debug,subsystem=info will return false.)
Co-authored-by: Marcin Rataj <lidel@lidel.org>
The
ipfs log --helptext is updated to recommend the correct environment variable, and the debug logging check is more robust when checking if debug logging should be enabled.When running
ipfs log --helpI noticed two environment variables I was unfamiliar with. This PR updates every place where IPFS_LOG_LEVEL was used, to GOLOG_LOG_LEVEL, and IPFS_LOG_FMT to GOLOG_LOG_FMT, but does not completely "sunset" the deprecated environment variables.The
IPFS_LOG_LEVELenvironment variable was still in use in the code, so I think fully removing it at this point would be premature, let me know if you think otherwise.NOTE: these env vars were documented as deprecated in #8833