-
Notifications
You must be signed in to change notification settings - Fork 10
/
exported.go
185 lines (151 loc) · 4.84 KB
/
exported.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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
// Copyright 2018 The cpchain authors
// This file is part of the cpchain library.
//
// The cpchain library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// The cpchain library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with the cpchain library. If not, see <http://www.gnu.org/licenses/>.
package log
import (
"io"
"github.com/sirupsen/logrus"
)
var (
root = New()
termTimeFormat = "01-02|15:04:05.000"
)
// ShowFilename show filename and position
func ShowFilename() {
root.skip()
root.ShowFilename()
}
func Root() *Logger {
return root
}
func getFields(ctx ...interface{}) logrus.Fields {
fields := make(logrus.Fields, len(ctx))
for i := 0; i < len(ctx); i += 2 {
k, ok := ctx[i].(string)
if !ok {
return nil
}
fields[k] = ctx[i+1]
}
return fields
}
// SetLevel sets the logger level.
func SetLevel(level logrus.Level) {
root.SetLevel(level)
}
// GetLevel returns the logger level.
func GetLevel() logrus.Level {
return root.GetLevel()
}
// SetOutput sets the logger output.
func SetOutput(output io.Writer) {
root.SetOutput(output)
}
// SetFormatter sets the logger formatter.
func SetFormatter(formatter logrus.Formatter) {
root.SetFormatter(formatter)
}
// Info logs a message at level Info on the standard logger.
func Info(msg string, ctx ...interface{}) {
root.Info(msg, ctx...)
}
// Print logs a message at level Info on the standard logger.
func Print(msg string, ctx ...interface{}) {
root.Print(msg, ctx...)
}
// Debug logs a message at level Debug on the standard logger.
func Debug(msg string, ctx ...interface{}) {
root.Debug(msg, ctx...)
}
// Warn logs a message at level Warn on the standard logger.
func Warn(msg string, ctx ...interface{}) {
root.Warn(msg, ctx...)
}
// Error logs a message at level Error on the standard logger.
func Error(msg string, ctx ...interface{}) {
root.Error(msg, ctx...)
}
// Panic logs a message at level Panic on the standard logger.
func Panic(msg string, ctx ...interface{}) {
root.Panic(msg, ctx...)
}
// Fatal logs a message at level Fatal on the standard logger then the process will exit with status set to 1.
func Fatal(msg string, ctx ...interface{}) {
root.Fatal(msg, ctx...)
}
// Debugf logs a message at level Debug on the standard logger.
func Debugf(format string, args ...interface{}) {
root.Debugf(format, args...)
}
// Printf logs a message at level Info on the standard logger.
func Printf(format string, args ...interface{}) {
root.Printf(format, args...)
}
// Infof logs a message at level Info on the standard logger.
func Infof(format string, args ...interface{}) {
root.Infof(format, args...)
}
// Warnf logs a message at level Warn on the standard logger.
func Warnf(format string, args ...interface{}) {
root.Warnf(format, args...)
}
// Warningf logs a message at level Warn on the standard logger.
func Warningf(format string, args ...interface{}) {
root.Warningf(format, args...)
}
// Errorf logs a message at level Error on the standard logger.
func Errorf(format string, args ...interface{}) {
root.Errorf(format, args...)
}
// Panicf logs a message at level Panic on the standard logger.
func Panicf(format string, args ...interface{}) {
root.Panicf(format, args...)
}
// Fatalf logs a message at level Fatal on the standard logger then the process will exit with status set to 1.
func Fatalf(format string, args ...interface{}) {
root.Fatalf(format, args...)
}
// Debugln logs a message at level Debug on the standard logger.
func Debugln(args ...interface{}) {
root.Debugln(args...)
}
// Println logs a message at level Info on the standard logger.
func Println(args ...interface{}) {
root.Println(args...)
}
// Infoln logs a message at level Info on the standard logger.
func Infoln(args ...interface{}) {
root.Infoln(args...)
}
// Warnln logs a message at level Warn on the standard logger.
func Warnln(args ...interface{}) {
root.Warnln(args...)
}
// Warningln logs a message at level Warn on the standard logger.
func Warningln(args ...interface{}) {
root.Warningln(args...)
}
// Errorln logs a message at level Error on the standard logger.
func Errorln(args ...interface{}) {
root.Errorln(args...)
}
// Panicln logs a message at level Panic on the standard logger.
func Panicln(args ...interface{}) {
root.Panicln(args...)
}
// Fatalln logs a message at level Fatal on the standard logger then the process will exit with status set to 1.
func Fatalln(args ...interface{}) {
root.Fatalln(args...)
}