Skip to content

Commit

Permalink
add func ParseLevel
Browse files Browse the repository at this point in the history
	target := log.NewConsoleTarget()
	target.MaxLevel = log.ParseLevel(os.Getenv("LOG_LEVEL"))
	logger.Targets = append(logger.Targets, target)
  • Loading branch information
ns5d committed Jan 7, 2021
1 parent 610cdd1 commit 2d91b38
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions logger.go
Expand Up @@ -52,6 +52,17 @@ func (l Level) String() string {
return "Unknown"
}

// ParseLevel retrun level by name (if not found return Debug)
func ParseLevel(levelName string) Level {
for k, v := range LevelNames {
if v == levelName {
return k
}
}

return LevelDebug
}

// Entry represents a log entry.
type Entry struct {
Level Level
Expand Down

0 comments on commit 2d91b38

Please sign in to comment.