yanic/main.go

43 lines
698 B
Go
Raw Normal View History

2017-09-17 01:26:19 +00:00
package main
2019-01-17 12:26:16 +00:00
import (
"os"
"github.com/bdlm/log"
stdLogger "github.com/bdlm/std/logger"
"github.com/FreifunkBremen/yanic/cmd"
)
type Hook struct{}
func (hook *Hook) Fire(entry *log.Entry) error {
switch entry.Level {
case log.PanicLevel:
entry.Logger.Out = os.Stderr
case log.FatalLevel:
entry.Logger.Out = os.Stderr
case log.ErrorLevel:
entry.Logger.Out = os.Stderr
case log.WarnLevel:
entry.Logger.Out = os.Stdout
case log.InfoLevel:
entry.Logger.Out = os.Stdout
case log.DebugLevel:
entry.Logger.Out = os.Stdout
default:
}
return nil
}
func (hook *Hook) Levels() []stdLogger.Level {
return log.AllLevels
}
2017-09-17 01:26:19 +00:00
func main() {
2019-01-17 12:26:16 +00:00
log.AddHook(&Hook{})
2017-09-17 01:26:19 +00:00
cmd.Execute()
}