func SetDebug(d bool) { // sort of unnecessary but hey, standards lock.Lock() defer lock.Unlock() debug = d protolog.SetLogger(protolog.GlobalLogger().AtLevel(protolog.Level_LEVEL_DEBUG)) }
func register() { protolog.SetLogger(protolog.NewLogger(NewPusher(globalPusherOptions), globalLoggerOptions)) }
func register() { protolog.SetLogger(protolog.NewLogger(newPusher(globalMarshaller, globalLogDebug), globalLoggerOptions)) }
// SetupLogging sets up logging. func SetupLogging(appName string, env Env) error { var pushers []protolog.Pusher if !env.DisableStderrLog { pushers = append( pushers, protolog.NewStandardWritePusher( protolog.NewFileFlusher( os.Stderr, ), ), ) } if env.LogDir != "" { pushers = append( pushers, protolog.NewStandardWritePusher( protolog.NewWriterFlusher( &lumberjack.Logger{ Filename: filepath.Join(env.LogDir, fmt.Sprintf("%s.log", appName)), MaxBackups: 3, }, ), ), ) } if env.SyslogNetwork != "" && env.SyslogAddress != "" { writer, err := syslog.Dial( env.SyslogNetwork, env.SyslogAddress, syslog.LOG_INFO, appName, ) if err != nil { return err } pushers = append( pushers, protosyslog.NewPusher( writer, protosyslog.PusherOptions{}, ), ) } if len(pushers) > 0 { protolog.SetLogger( protolog.NewStandardLogger( protolog.NewMultiPusher( pushers..., ), ), ) } else { protolog.SetLogger( protolog.DiscardLogger, ) } protolog.RedirectStdLogger() if env.LogLevel != "" { levelValue, ok := protolog.Level_value[fmt.Sprintf("LEVEL_%s", strings.ToUpper(env.LogLevel))] if !ok { return fmt.Errorf("pkglog: unknown log level: %s", env.LogLevel) } protolog.SetLevel(protolog.Level(levelValue)) } return nil }