/
global.go
99 lines (81 loc) · 2.5 KB
/
global.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
package logging
import (
"errors"
"time"
"github.com/getsentry/sentry-go"
"go.uber.org/zap"
)
// Debug ...
func Debug(msg string, fields ...zap.Field) {
zapLogger.WithOptions(zap.AddCallerSkip(1)).Debug(msg, fields...)
}
// Info ...
func Info(msg string, fields ...zap.Field) {
zapLogger.WithOptions(zap.AddCallerSkip(1)).Info(msg, fields...)
}
// Warn ...
func Warn(msg string, fields ...zap.Field) {
zapLogger.WithOptions(zap.AddCallerSkip(1)).Warn(msg, fields...)
}
// Error ...
func Error(msg string, fields ...zap.Field) {
zapLogger.WithOptions(zap.AddCallerSkip(1)).Error(msg, fields...)
}
// DPanic ...
func DPanic(msg string, fields ...zap.Field) {
zapLogger.WithOptions(zap.AddCallerSkip(1)).DPanic(msg, fields...)
}
// Panic ...
func Panic(msg string, fields ...zap.Field) {
zapLogger.WithOptions(zap.AddCallerSkip(1)).Panic(msg, fields...)
}
// Fatal ...
func Fatal(msg string, fields ...zap.Field) {
zapLogger.WithOptions(zap.AddCallerSkip(1)).Fatal(msg, fields...)
}
// Debugf ...
func Debugf(template string, args ...interface{}) {
zapLogger.WithOptions(zap.AddCallerSkip(1)).Sugar().Debugf(template, args...)
}
// Infof ...
func Infof(template string, args ...interface{}) {
zapLogger.WithOptions(zap.AddCallerSkip(1)).Sugar().Infof(template, args...)
}
// Warnf ...
func Warnf(template string, args ...interface{}) {
zapLogger.WithOptions(zap.AddCallerSkip(1)).Sugar().Warnf(template, args...)
}
// Errorf ...
func Errorf(template string, args ...interface{}) {
zapLogger.WithOptions(zap.AddCallerSkip(1)).Sugar().Errorf(template, args...)
}
// DPanicf ...
func DPanicf(template string, args ...interface{}) {
zapLogger.WithOptions(zap.AddCallerSkip(1)).Sugar().DPanicf(template, args...)
}
// Panicf ...
func Panicf(template string, args ...interface{}) {
zapLogger.WithOptions(zap.AddCallerSkip(1)).Sugar().Panicf(template, args...)
}
// Fatalf ...
func Fatalf(template string, args ...interface{}) {
zapLogger.WithOptions(zap.AddCallerSkip(1)).Sugar().Fatalf(template, args...)
}
// SentryCaptureMessage ...
func SentryCaptureMessage(msg string) error {
if SentryClient() == nil {
return errors.New("sentry client is nil, please set the sentry dsn config")
}
defer sentry.Flush(2 * time.Second)
sentry.CaptureMessage(msg)
return nil
}
// SentryCaptureException ...
func SentryCaptureException(err error) error {
if SentryClient() == nil {
return errors.New("sentry client is nil, please set the sentry dsn config")
}
defer sentry.Flush(2 * time.Second)
sentry.CaptureException(err)
return nil
}