forked from wailsapp/wails
-
Notifications
You must be signed in to change notification settings - Fork 0
/
logger.go
54 lines (44 loc) · 946 Bytes
/
logger.go
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
51
52
53
54
package logger
import (
"fmt"
"strings"
)
// LogLevel is an unsigned 8bit int
type LogLevel uint8
const (
// TRACE level
TRACE LogLevel = 1
// DEBUG level logging
DEBUG LogLevel = 2
// INFO level logging
INFO LogLevel = 3
// WARNING level logging
WARNING LogLevel = 4
// ERROR level logging
ERROR LogLevel = 5
)
var logLevelMap = map[string]LogLevel{
"trace": TRACE,
"debug": DEBUG,
"info": INFO,
"warning": WARNING,
"error": ERROR,
}
func StringToLogLevel(input string) (LogLevel, error) {
result, ok := logLevelMap[strings.ToLower(input)]
if !ok {
return ERROR, fmt.Errorf("invalid log level: %s", input)
}
return result, nil
}
// Logger specifies the methods required to attach
// a logger to a Wails application
type Logger interface {
Print(message string)
Trace(message string)
Debug(message string)
Info(message string)
Warning(message string)
Error(message string)
Fatal(message string)
}