/
echologger.go
153 lines (122 loc) · 3.83 KB
/
echologger.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
package server
import (
"fmt"
"io"
"os"
"github.com/labstack/gommon/log"
"github.com/fastbill/go-service-toolkit/v4/observance"
)
// Logger is a wrapper for the logrus fieldlogger that fulfills the echo logger interface
type Logger struct {
observance.Logger
}
// Output returns the default output.
func (l Logger) Output() io.Writer {
return os.Stdout
}
// Prefix is NOT IMPLEMENTED, it is only present to fulfill the echo logger interface
func (l Logger) Prefix() string {
l.Error("trying to use unimplemented log method Prefix")
return ""
}
// SetPrefix is NOT IMPLEMENTED, it is only present to fulfill the echo logger interface
func (l Logger) SetPrefix(p string) {
l.Error("trying to use unimplemented log method SetPrefix")
}
// Level is NOT IMPLEMENTED, it is only present to fulfill the echo logger interface
func (l Logger) Level() log.Lvl {
l.Error("trying to use unimplemented log method Level")
return 0
}
// SetLevel is NOT IMPLEMENTED, it is only present to fulfill the echo logger interface
func (l Logger) SetLevel(v log.Lvl) {
l.Error("trying to use unimplemented log method SetLevel")
}
// SetHeader is NOT IMPLEMENTED, it is only present to fulfill the echo logger interface
func (l Logger) SetHeader(h string) {
l.Error("trying to use unimplemented log method SetHeader")
}
// Panic implements echo.Logger#Panic.
func (l Logger) Panic(i ...interface{}) {
l.Error(fmt.Sprintf("%v", i))
}
// Panicf implements echo.Logger#Panicf.
func (l Logger) Panicf(format string, args ...interface{}) {
l.Error(fmt.Sprintf(format, args...))
}
// Panicj implements echo.Logger#Panicj.
func (l Logger) Panicj(j log.JSON) {
l.Error(fmt.Sprintf("%+v", j))
}
// Fatal implements echo.Logger#Fatal.
func (l Logger) Fatal(i ...interface{}) {
l.Error(fmt.Sprintf("%v", i))
}
// Fatalf implements echo.Logger#Fatalf.
func (l Logger) Fatalf(format string, args ...interface{}) {
l.Error(fmt.Sprintf(format, args...))
}
// Fatalj implements echo.Logger#Fatalj.
func (l Logger) Fatalj(j log.JSON) {
l.Error(fmt.Sprintf("%+v", j))
}
// Error implements echo.Logger#Error.
func (l Logger) Error(i ...interface{}) {
l.Logger.Error(fmt.Sprintf("%v", i))
}
// Errorf implements echo.Logger#Errorf.
func (l Logger) Errorf(format string, args ...interface{}) {
l.Error(fmt.Sprintf(format, args...))
}
// Errorj implements echo.Logger#Errorj.
func (l Logger) Errorj(j log.JSON) {
l.Error(fmt.Sprintf("%+v", j))
}
// Warn implements echo.Logger#Warn.
func (l Logger) Warn(i ...interface{}) {
l.Logger.Warn(fmt.Sprintf("%v", i))
}
// Warnf implements echo.Logger#Warnf.
func (l Logger) Warnf(format string, args ...interface{}) {
l.Warn(fmt.Sprintf(format, args...))
}
// Warnj implements echo.Logger#Warnj.
func (l Logger) Warnj(j log.JSON) {
l.Warn(fmt.Sprintf("%+v", j))
}
// Info implements echo.Logger#Info.
func (l Logger) Info(i ...interface{}) {
l.Logger.Info(fmt.Sprintf("%v", i))
}
// Infof implements echo.Logger#Infof.
func (l Logger) Infof(format string, args ...interface{}) {
l.Info(fmt.Sprintf(format, args...))
}
// Infoj implements echo.Logger#Infoj.
func (l Logger) Infoj(j log.JSON) {
l.Info(fmt.Sprintf("%+v", j))
}
// Debug implements echo.Logger#Debug.
func (l Logger) Debug(i ...interface{}) {
l.Logger.Debug(fmt.Sprintf("%v", i))
}
// Debugf implements echo.Logger#Debugf.
func (l Logger) Debugf(format string, args ...interface{}) {
l.Debug(fmt.Sprintf(format, args...))
}
// Debugj implements echo.Logger#Debugj.
func (l Logger) Debugj(j log.JSON) {
l.Debug(fmt.Sprintf("%+v", j))
}
// Print implements echo.Logger#Print.
func (l Logger) Print(i ...interface{}) {
l.Info(fmt.Sprintf("%v", i))
}
// Printf implements echo.Logger#Printf.
func (l Logger) Printf(format string, args ...interface{}) {
l.Info(fmt.Sprintf(format, args...))
}
// Printj implements echo.Logger#Printj.
func (l Logger) Printj(j log.JSON) {
l.Info(fmt.Sprintf("%+v", j))
}