// SetLogLevel changes the log level of a specific subsystem // name=="*" changes all subsystems func SetLogLevel(name, level string) error { lvl, err := logging.LogLevel(level) if err != nil { return err } // wildcard, change all if name == "*" { SetAllLoggers(lvl) return nil } // Check if we have a logger by that name if _, ok := loggers[name]; !ok { return ErrNoSuchLogger } logging.SetLevel(lvl, name) return nil }
// SetupLogging will initialize the logger backend and set the flags. func SetupLogging() { fmt := LogFormats[os.Getenv(envLoggingFmt)] if fmt == "" { fmt = LogFormats[defaultLogFormat] } backend := logging.NewLogBackend(os.Stderr, "", 0) logging.SetBackend(backend) logging.SetFormatter(logging.MustStringFormatter(fmt)) lvl := logging.ERROR if logenv := os.Getenv(envLogging); logenv != "" { var err error lvl, err = logging.LogLevel(logenv) if err != nil { } } SetAllLoggers(lvl) }