func setupLogging() { // Setup the syslog backend writer, err := syslog.New(syslog.LOG_USER, "gobs") if err != nil { log.Alertf("Unable to initialize syslogging (%v)", err.Error()) } syslogger := log.NewSyslogBackend(conf.Verbose, writer) log.AddBackend("syslog", syslogger) // Setup the std backend log.GetBackend("std").SetLevel(conf.Verbose) // Setup the logfile backend // @Todo }
func setup() { flag.Parse() var verbose log.Level switch { case *flagDebug: verbose = log.DEBUG case *flagVVerbose: verbose = log.INFO case *flagVerbose: verbose = log.WARN case *flagQuiet: verbose = log.ALERT default: verbose = log.ERROR } // Apply command-line verbosity first logger := dlog.New(os.Stdout, "", 0) backend := log.NewStdBackend(verbose, logger) log.AddBackend("std", backend) // Load the configuration file conf = config.New(verbose) loadConfiguration() // Enforce command-line verbosity over configuration if verbose != log.ERROR { conf.Verbose = verbose } setupLogging() // Enforce command-line testing over configuration conf.Test = *flagTest }