-
Notifications
You must be signed in to change notification settings - Fork 1
/
std.go
117 lines (91 loc) · 1.74 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/*
logy std 标准输出实现
sam
2020-09-29
*/
package logy
import (
"io"
"os"
"sync"
"time"
)
type mutexWriter struct {
m sync.Mutex
w io.Writer
}
// WriteLog
func (mw *mutexWriter) WriteLog(t time.Time, level int, s []byte) {
mw.m.Lock()
mw.w.Write(s)
mw.m.Unlock()
}
// NewMutexWriter returns a currently safe writer.
func NewMutexWriter(w io.Writer) Writer {
return writer{w: w}
}
var std *Logger
func init() {
std = NewLogger(NewMutexWriter(os.Stdout), LstdFlags, LevelDebug)
std.SetCallDepth(std.CallDepth() + 1)
}
func Flags() int {
return std.Flags()
}
func SetFlags(flag int) {
std.SetFlags(flag)
}
func SetLevel(level int) {
std.SetLevel(level)
}
func SetOutput(w Writer, prefix string) {
std.SetOutput(w, prefix)
}
func SetCallDepth(depth int) {
std.SetCallDepth(depth)
}
func CallDepth() int {
return std.CallDepth()
}
func Debug(v ...interface{}) {
std.Debug("%v", v...)
}
func Info(v ...interface{}) {
std.Info("%v", v...)
}
func Notice(v ...interface{}) {
std.Notice("%v", v...)
}
func Warn(v ...interface{}) {
std.Warn("%v", v...)
}
func Error(v ...interface{}) {
std.Error("%v", v...)
}
func Panic(v ...interface{}) {
std.Panic("%v", v...)
}
func Fatal(v ...interface{}) {
std.Fatal("%v", v...)
}
func Debugf(format string, v ...interface{}) {
std.Debug(format, v...)
}
func Infof(format string, v ...interface{}) {
std.Info(format, v...)
}
func Noticef(format string, v ...interface{}) {
std.Notice(format, v...)
}
func Warnf(format string, v ...interface{}) {
std.Warn(format, v...)
}
func Errorf(format string, v ...interface{}) {
std.Error(format, v...)
}
func Panicf(format string, v ...interface{}) {
std.Panic(format, v...)
}
func Fatalf(format string, v ...interface{}) {
std.Fatal(format, v...)
}