wings/tools/logging.go
Jakob Schrettenbrunner 7055f0c9b2 update import paths
update Readme with shields
2017-06-26 20:44:37 +02:00

35 lines
724 B
Go

package tools
import (
"time"
rotatelogs "github.com/lestrrat/go-file-rotatelogs"
"github.com/rifflock/lfshook"
log "github.com/sirupsen/logrus"
)
// ConfigureLogging configures logrus to our needs
func ConfigureLogging() error {
log.SetFormatter(&log.TextFormatter{
DisableTimestamp: true,
})
path := "logs/"
writer := rotatelogs.New(
path+"pterodactyld.%Y%m%d-%H%M.log",
rotatelogs.WithLinkName(path),
rotatelogs.WithMaxAge(time.Duration(86400)*time.Second),
rotatelogs.WithRotationTime(time.Duration(604800)*time.Second),
)
log.AddHook(lfshook.NewHook(lfshook.WriterMap{
log.InfoLevel: writer,
log.ErrorLevel: writer,
log.FatalLevel: writer,
log.PanicLevel: writer,
}))
return nil
}