You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
576 B

package main
import (
log "github.com/sirupsen/logrus"
)
var logConstants = map[string]log.Level{
":fatal": log.FatalLevel,
":error": log.ErrorLevel,
":warn": log.WarnLevel,
":info": log.InfoLevel,
":debug": log.DebugLevel,
":verbose": log.TraceLevel,
":all": log.TraceLevel,
}
func stringToLogConstant(c string) log.Level {
level, ok := logConstants[c]
if !ok {
level = log.FatalLevel
}
return level
}
// SetLogrusLevel sets Logrus logging level from a string
func SetLogrusLevel(level string) {
log.SetLevel(stringToLogConstant(level))
}