From 3fd33ef6cf42ee0f5ab9eea98eb4c055f85babd4 Mon Sep 17 00:00:00 2001 From: Adrian Lanzafame Date: Fri, 1 Nov 2019 13:52:12 +1000 Subject: [PATCH 1/2] add IPFS_* env vars back for transitionary release of go-log --- oldlog.go | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/oldlog.go b/oldlog.go index c7c58a0..42ff121 100644 --- a/oldlog.go +++ b/oldlog.go @@ -22,6 +22,14 @@ func init() { // Logging environment variables const ( + // IPFS_* prefixed env vars kept for backwards compatibility + // for this release. They will not be available in the next + // release. + // + // GOLOG_* env vars take precedences over IPFS_* env vars. + envIPFSLogging = "IPFS_LOGGING" + envIPFSLoggingFmt = "IPFS_LOGGING_FMT" + envLogging = "GOLOG_LOG_LEVEL" envLoggingFmt = "GOLOG_LOG_FMT" @@ -44,9 +52,12 @@ var levels = make(map[string]zap.AtomicLevel) var zapCfg = zap.NewProductionConfig() func SetupLogging() { - + loggingFmt := os.Getenv(envLoggingFmt) + if loggingFmt == "" { + loggingFmt = os.Getenv(envIPFSLoggingFmt) + } // colorful or plain - switch os.Getenv(envLoggingFmt) { + switch loggingFmt { case "nocolor": zapCfg.Encoding = "console" zapCfg.EncoderConfig.EncodeLevel = zapcore.CapitalLevelEncoder @@ -69,7 +80,12 @@ func SetupLogging() { // set the backend(s) lvl := LevelError - if logenv := os.Getenv(envLogging); logenv != "" { + logenv := os.Getenv(envLogging) + if logenv == "" { + logenv = os.Getenv(envIPFSLogging) + } + + if logenv != "" { var err error lvl, err = LevelFromString(logenv) if err != nil { From 9ce8380833f36e86523fc3800416bf05c655c5e1 Mon Sep 17 00:00:00 2001 From: Adrian Lanzafame Date: Fri, 1 Nov 2019 13:53:37 +1000 Subject: [PATCH 2/2] make go happy by adding go required version; set to the same as go-ipfs and go-libp2p-core --- go.mod | 2 ++ 1 file changed, 2 insertions(+) diff --git a/go.mod b/go.mod index c6ebe97..f374369 100644 --- a/go.mod +++ b/go.mod @@ -9,3 +9,5 @@ require ( go.uber.org/multierr v1.1.0 // indirect go.uber.org/zap v1.10.0 ) + +go 1.12