-
Notifications
You must be signed in to change notification settings - Fork 0
/
service.go
89 lines (69 loc) · 2.07 KB
/
service.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
package logger
import (
"context"
"github.com/rudianto-dev/gotemp-sdk/pkg/helper"
"github.com/rudianto-dev/gotemp-sdk/pkg/utils"
)
func (s *Logger) Info(args ...interface{}) {
s.Logrus.Info(args...)
}
func (s *Logger) Warning(args ...interface{}) {
s.Logrus.Warning(args...)
}
func (s *Logger) Error(args ...interface{}) {
s.Logrus.Error(args...)
}
func (s *Logger) Fatal(args ...interface{}) {
s.Logrus.Fatal(args...)
}
func (s *Logger) Panic(args ...interface{}) {
s.Logrus.Panic(args...)
}
func (s *Logger) Infof(format string, args ...interface{}) {
s.Logrus.Infof(format, args...)
}
func (s *Logger) Warningf(format string, args ...interface{}) {
s.Logrus.Warningf(format, args...)
}
func (s *Logger) Errorf(format string, args ...interface{}) {
s.Logrus.Errorf(format, args...)
}
func (s *Logger) Fatalf(format string, args ...interface{}) {
s.Logrus.Fatalf(format, args...)
}
func (s *Logger) Panicf(format string, args ...interface{}) {
s.Logrus.Panicf(format, args...)
}
func (s *Logger) InfoWithField(fields Fields) {
var arg map[string]interface{} = fields
s.Logrus.WithFields(arg).Println()
}
func (s *Logger) ErrorWithField(fields Fields) {
var arg map[string]interface{} = fields
s.Logrus.WithFields(arg).Errorln()
}
func (s *Logger) InfoWithContext(ctx context.Context, stage utils.ErrorStage, args ...interface{}) {
s.InfoContextWithField(ctx, map[string]interface{}{
"stage": stage,
"message": args,
})
}
func (s *Logger) ErrorWithContext(ctx context.Context, stage utils.ErrorStage, args ...interface{}) {
s.ErrorContextWithField(ctx, map[string]interface{}{
"stage": stage,
"message": args,
})
}
func (s *Logger) InfoContextWithField(ctx context.Context, fields Fields) {
var arg map[string]interface{} = fields
arg["req_id"] = helper.GetReqID(ctx)
s.Logrus.WithFields(arg).Println()
}
func (s *Logger) ErrorContextWithField(ctx context.Context, fields Fields) {
var arg map[string]interface{} = fields
arg["req_id"] = helper.GetReqID(ctx)
s.Logrus.WithFields(arg).Errorln()
}
func (s *Logger) CloseStream() {
s.Logrus.Writer().Close()
}