-
Notifications
You must be signed in to change notification settings - Fork 147
Expand file tree
/
Copy pathentrylogwrapper.go
More file actions
184 lines (148 loc) · 5.13 KB
/
entrylogwrapper.go
File metadata and controls
184 lines (148 loc) · 5.13 KB
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
/*
* Copyright 2018 The CovenantSQL Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package log
import (
"time"
"github.com/sirupsen/logrus"
)
// Entry defines alias for logrus entry.
type Entry logrus.Entry
// NewEntry returns new entry for logrus logger.
func NewEntry(logger *Logger) *Entry {
return &Entry{
Logger: (*logrus.Logger)(logger),
// Default is five fields, give a little extra room
Data: make(logrus.Fields, 5),
}
}
// Returns the string representation from the reader and ultimately the formatter.
func (entry *Entry) String() (string, error) {
return (*logrus.Entry)(entry).String()
}
// WithError adds an error as single field (using the key defined in ErrorKey) to the Entry.
func (entry *Entry) WithError(err error) *Entry {
return (*Entry)((*logrus.Entry)(entry).WithError(err))
}
// WithField add a single field to the Entry.
func (entry *Entry) WithField(key string, value interface{}) *Entry {
return (*Entry)((*logrus.Entry)(entry).WithField(key, value))
}
// WithFields add a map of fields to the Entry.
func (entry *Entry) WithFields(fields Fields) *Entry {
return (*Entry)((*logrus.Entry)(entry).WithFields((logrus.Fields)(fields)))
}
// WithTime overrides the time of the Entry.
func (entry *Entry) WithTime(t time.Time) *Entry {
return &Entry{Logger: entry.Logger, Data: entry.Data, Time: t}
}
// Debug record a new debug level log.
func (entry *Entry) Debug(args ...interface{}) {
(*logrus.Entry)(entry).Debug(args...)
}
// Print record a new non-level log.
func (entry *Entry) Print(args ...interface{}) {
(*logrus.Entry)(entry).Print(args...)
}
// Info record a new info level log.
func (entry *Entry) Info(args ...interface{}) {
(*logrus.Entry)(entry).Info(args...)
}
// Warn record a new warning level log.
func (entry *Entry) Warn(args ...interface{}) {
(*logrus.Entry)(entry).Warn(args...)
}
// Warning record a new warning level log.
func (entry *Entry) Warning(args ...interface{}) {
(*logrus.Entry)(entry).Warning(args...)
}
// Error record a new error level log.
func (entry *Entry) Error(args ...interface{}) {
(*logrus.Entry)(entry).Error(args...)
}
// Fatal record a fatal level log.
func (entry *Entry) Fatal(args ...interface{}) {
(*logrus.Entry)(entry).Fatal(args...)
}
// Panic record a panic level log.
func (entry *Entry) Panic(args ...interface{}) {
(*logrus.Entry)(entry).Panic(args...)
}
// Entry Printf family functions
// Debugf record a debug level log.
func (entry *Entry) Debugf(format string, args ...interface{}) {
(*logrus.Entry)(entry).Debugf(format, args...)
}
// Infof record a info level log.
func (entry *Entry) Infof(format string, args ...interface{}) {
(*logrus.Entry)(entry).Infof(format, args...)
}
// Printf record a new non-level log.
func (entry *Entry) Printf(format string, args ...interface{}) {
(*logrus.Entry)(entry).Printf(format, args...)
}
// Warnf record a warning level log.
func (entry *Entry) Warnf(format string, args ...interface{}) {
(*logrus.Entry)(entry).Warnf(format, args...)
}
// Warningf record a warning level log.
func (entry *Entry) Warningf(format string, args ...interface{}) {
(*logrus.Entry)(entry).Warningf(format, args...)
}
// Errorf record a error level log.
func (entry *Entry) Errorf(format string, args ...interface{}) {
(*logrus.Entry)(entry).Errorf(format, args...)
}
// Fatalf record a fatal level log.
func (entry *Entry) Fatalf(format string, args ...interface{}) {
(*logrus.Entry)(entry).Fatalf(format, args...)
}
// Panicf record a panic level log.
func (entry *Entry) Panicf(format string, args ...interface{}) {
(*logrus.Entry)(entry).Panicf(format, args...)
}
// Entry Println family functions
// Debugln record a debug level log.
func (entry *Entry) Debugln(args ...interface{}) {
(*logrus.Entry)(entry).Debugln(args...)
}
// Infoln record a info level log.
func (entry *Entry) Infoln(args ...interface{}) {
(*logrus.Entry)(entry).Infoln(args...)
}
// Println record a non-level log.
func (entry *Entry) Println(args ...interface{}) {
(*logrus.Entry)(entry).Println(args...)
}
// Warnln record a warning level log.
func (entry *Entry) Warnln(args ...interface{}) {
(*logrus.Entry)(entry).Warnln(args...)
}
// Warningln record a warning level log.
func (entry *Entry) Warningln(args ...interface{}) {
(*logrus.Entry)(entry).Warningln(args...)
}
// Errorln record a error level log.
func (entry *Entry) Errorln(args ...interface{}) {
(*logrus.Entry)(entry).Errorln(args...)
}
// Fatalln record a fatal level log.
func (entry *Entry) Fatalln(args ...interface{}) {
(*logrus.Entry)(entry).Fatalln(args...)
}
// Panicln record a panic level log.
func (entry *Entry) Panicln(args ...interface{}) {
(*logrus.Entry)(entry).Panicln(args...)
}