-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstd.go
101 lines (78 loc) · 1.57 KB
/
std.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
package llog
import (
"fmt"
"io"
"os"
)
var std *Logger
func init() {
std = &Logger{
out: &mutexWriter{
Writer: os.Stderr,
},
}
}
func Default() *Logger {
return std
}
func SetTag(tag string) {
std.tag = tag
}
func SetOutput(out io.Writer) {
std.out = &mutexWriter{
Writer: out,
}
}
func SetLevelString(s string) {
std.setLevelString(s)
}
func SetLevel(level Level) {
std.setLevel(level)
}
func SetFileAndLine(included bool) {
std.fileAndLine = included
}
func WithTag(tag string) *Logger {
return std.WithTag(tag)
}
func WithLevel(level Level) *Logger {
return std.WithLevel(level)
}
func WithOutput(out io.Writer) *Logger {
return std.WithOutput(out)
}
func WithFileAndLine(included bool) *Logger {
return std.WithFileAndLine(included)
}
func Error(v ...any) {
std.output(LevelError, fmt.Sprint(v...))
}
func Errorf(format string, v ...any) {
std.output(LevelError, fmt.Sprintf(format, v...))
}
func Warn(v ...any) {
std.output(LevelWarning, fmt.Sprint(v...))
}
func Warnf(format string, v ...any) {
std.output(LevelWarning, fmt.Sprintf(format, v...))
}
func Info(v ...any) {
std.output(LevelInfo, fmt.Sprint(v...))
}
func Infof(format string, v ...any) {
std.output(LevelInfo, fmt.Sprintf(format, v...))
}
func Debug(v ...any) {
std.output(LevelDebug, fmt.Sprint(v...))
}
func Debugf(format string, v ...any) {
std.output(LevelDebug, fmt.Sprintf(format, v...))
}
func Fatal(v ...any) {
std.output(LevelError, fmt.Sprint(v...))
os.Exit(1)
}
func Fatalf(format string, v ...any) {
std.output(LevelError, fmt.Sprintf(format, v...))
os.Exit(1)
}