-
Notifications
You must be signed in to change notification settings - Fork 2
/
loader.go
62 lines (50 loc) · 1.48 KB
/
loader.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
package golog
import (
"context"
"sync"
"go.uber.org/zap"
)
var (
once sync.Once
singleton LoggerInterface
)
// Loader to construct logger. So logger will
func Load(config Config) LoggerInterface {
once.Do(func() {
singleton = NewLogger(config)
})
return singleton
}
// Debug logs a message at DebugLevel.
func Debug(ctx context.Context, msg string, fields ...zap.Field) {
singleton.Debug(ctx, msg, fields...)
}
// Info logs a message at InfoLevel.
func Info(ctx context.Context, msg string, fields ...zap.Field) {
singleton.Info(ctx, msg, fields...)
}
// Warn logs a message at WarnLevel.
func Warn(ctx context.Context, msg string, fields ...zap.Field) {
singleton.Warn(ctx, msg, fields...)
}
// Error logs a message at ErrorLevel.
func Error(ctx context.Context, msg string, err error, fields ...zap.Field) {
singleton.Error(ctx, msg, err, fields...)
}
// Fatal logs a message at FatalLevel.
//
// The logger then calls os.Exit(1), even if logging at FatalLevel is
// disabled.
func Fatal(ctx context.Context, msg string, err error, fields ...zap.Field) {
singleton.Fatal(ctx, msg, err, fields...)
}
// Panic logs a message at PanicLevel.
//
// The logger then panics, even if logging at PanicLevel is disabled.
func Panic(ctx context.Context, msg string, err error, fields ...zap.Field) {
singleton.Panic(ctx, msg, err, fields...)
}
// TDR (Transaction Detail Request) consist of request and response log
func TDR(ctx context.Context, model LogModel) {
singleton.TDR(ctx, model)
}