2017-09-17 03:26:19 +02:00
|
|
|
package main
|
|
|
|
|
2019-01-17 13:26:16 +01:00
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
|
|
|
|
"github.com/bdlm/log"
|
|
|
|
stdLogger "github.com/bdlm/std/logger"
|
|
|
|
|
|
|
|
"github.com/FreifunkBremen/yanic/cmd"
|
|
|
|
)
|
|
|
|
|
2019-02-27 02:51:01 +01:00
|
|
|
type hook struct{}
|
2019-01-17 13:26:16 +01:00
|
|
|
|
2019-02-27 02:51:01 +01:00
|
|
|
func (h *hook) Fire(entry *log.Entry) error {
|
2019-01-17 13:26:16 +01:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2019-02-27 02:51:01 +01:00
|
|
|
func (h *hook) Levels() []stdLogger.Level {
|
2019-01-17 13:26:16 +01:00
|
|
|
return log.AllLevels
|
|
|
|
}
|
2017-09-17 03:26:19 +02:00
|
|
|
|
|
|
|
func main() {
|
2019-02-27 02:51:01 +01:00
|
|
|
log.AddHook(&hook{})
|
2019-01-17 13:26:16 +01:00
|
|
|
|
2017-09-17 03:26:19 +02:00
|
|
|
cmd.Execute()
|
|
|
|
}
|