aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/felix/logger/level.go
blob: 73fa57df1a7ec7b4d87b0ef4008e8740b52bb098 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package logger

import "strings"

// Level defines the logger output level
type Level int

const (
	// NoLevel is prior to being defined
	NoLevel Level = 0
	// Debug is for development
	Debug Level = 1
	// Info are for interesting runtime events
	Info Level = 2
	// Warn is for almost errors
	Warn Level = 3
	// Error is a runtime problem
	Error Level = 4
)

func (lvl Level) String() string {
	switch lvl {
	case 1:
		return "debug"
	case 2:
		return "info"
	case 3:
		return "warn"
	case 4:
		return "error"
	default:
		return "unknown"
	}
}

// LevelFromString helps select a level
func LevelFromString(l string) Level {
	switch strings.ToLower(l) {
	case "debug":
		return Debug
	case "warn":
		return Warn
	case "Info":
		return Info
	case "Error":
		return Error
	default:
		return NoLevel
	}
}