Commit 0631a394 authored by Henry's avatar Henry

cleaned up SetupLogging()

parent afa5b7fc
......@@ -86,10 +86,7 @@ func ipfsCmd(c *commander.Command, args []string) error {
}
func main() {
u.Debug = false
// setup logging
// u.SetupLogging() done in an init() block now.
u.Debug = u.GetenvBool("IPFS_DEBUG")
// if debugging, setup profiling.
if u.Debug {
......
......@@ -30,25 +30,23 @@ func SetupLogging() {
logging.SetBackend(backend)
logging.SetFormatter(logging.MustStringFormatter(LogFormat))
// always print critical and error?
SetAllLoggers(logging.CRITICAL)
SetAllLoggers(logging.ERROR)
lvl := logging.ERROR
if logenv := os.Getenv("IPFS_LOGGING"); logenv != "" {
lvl, err := logging.LogLevel(logenv)
var err error
lvl, err = logging.LogLevel(logenv)
if err != nil {
log.Error("logging.LogLevel() Error: %q\n", err)
} else {
SetAllLoggers(lvl)
log.Error("logging.LogLevel() Error: %q", err)
lvl = logging.ERROR // reset to ERROR, could be undefined now(?)
}
}
if GetenvBool("IPFS_DEBUG") {
log.Info("enabling debug printing")
Debug = true
SetAllLoggers(logging.DEBUG)
if Debug {
lvl = logging.DEBUG
}
SetAllLoggers(lvl)
}
// SetAllLoggers changes the logging.Level of all loggers to lvl
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment