-
Notifications
You must be signed in to change notification settings - Fork 19
/
zap.go
50 lines (40 loc) · 978 Bytes
/
zap.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
package log
import (
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
)
// Field log field
type Field = zap.Field
// Option log Option
type Option = zap.Option
// Logger logger
type Logger = zap.Logger
// Level log level
type Level = zapcore.Level
// all log level
const (
DebugLevel Level = iota - 1
InfoLevel
WarnLevel
ErrorLevel
PanicLevel
FatalLevel
)
// Any constructs a field with the given key and value
func Any(key string, val interface{}) Field {
return zap.Any(key, val)
}
// Error is shorthand for the common idiom NamedError("error", err).
func Error(err error) Field {
return zap.Error(err)
}
// L returns the global Logger, which can be reconfigured with ReplaceGlobals.
// It's safe for concurrent use.
func L() *Logger {
return zap.L()
}
// With creates a child logger and adds structured context to it. Fields added
// to the child don't affect the parent, and vice versa.
func With(fields ...Field) *Logger {
return zap.L().With(fields...)
}