Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/components/common-go/log/export.go
2498 views
1
// Copyright (c) 2020 Gitpod GmbH. All rights reserved.
2
// Licensed under the GNU Affero General Public License (AGPL).
3
// See License.AGPL.txt in the project root for license information.
4
5
package log
6
7
import (
8
"context"
9
"time"
10
11
"github.com/sirupsen/logrus"
12
)
13
14
// WithError creates an entry from the standard logger and adds an error to it, using the value defined in ErrorKey as key.
15
func WithError(err error) *logrus.Entry {
16
return Log.WithError(err)
17
}
18
19
// WithContext creates an entry from the standard logger and adds a context to it.
20
func WithContext(ctx context.Context) *logrus.Entry {
21
return Log.WithContext(ctx)
22
}
23
24
// WithField creates an entry from the standard logger and adds a field to
25
// it. If you want multiple fields, use `WithFields`.
26
//
27
// Note that it doesn't log until you call Debug, Print, Info, Warn, Fatal
28
// or Panic on the Entry it returns.
29
func WithField(key string, value interface{}) *logrus.Entry {
30
return Log.WithField(key, value)
31
}
32
33
// WithFields creates an entry from the standard logger and adds multiple
34
// fields to it. This is simply a helper for `WithField`, invoking it
35
// once for each field.
36
//
37
// Note that it doesn't log until you call Debug, Print, Info, Warn, Fatal
38
// or Panic on the Entry it returns.
39
func WithFields(fields logrus.Fields) *logrus.Entry {
40
return Log.WithFields(fields)
41
}
42
43
// WithTime creats an entry from the standard logger and overrides the time of
44
// logs generated with it.
45
//
46
// Note that it doesn't log until you call Debug, Print, Info, Warn, Fatal
47
// or Panic on the Entry it returns.
48
func WithTime(t time.Time) *logrus.Entry {
49
return Log.WithTime(t)
50
}
51
52
// Trace logs a message at level Trace on the standard logger.
53
func Trace(args ...interface{}) {
54
Log.Trace(args...)
55
}
56
57
// Debug logs a message at level Debug on the standard logger.
58
func Debug(args ...interface{}) {
59
Log.Debug(args...)
60
}
61
62
// Print logs a message at level Info on the standard logger.
63
func Print(args ...interface{}) {
64
Log.Print(args...)
65
}
66
67
// Info logs a message at level Info on the standard logger.
68
func Info(args ...interface{}) {
69
Log.Info(args...)
70
}
71
72
// Warn logs a message at level Warn on the standard logger.
73
func Warn(args ...interface{}) {
74
Log.Warn(args...)
75
}
76
77
// Warning logs a message at level Warn on the standard logger.
78
func Warning(args ...interface{}) {
79
Log.Warning(args...)
80
}
81
82
// Error logs a message at level Error on the standard logger.
83
func Error(args ...interface{}) {
84
Log.Error(args...)
85
}
86
87
// Panic logs a message at level Panic on the standard logger.
88
func Panic(args ...interface{}) {
89
Log.Panic(args...)
90
}
91
92
// Fatal logs a message at level Fatal on the standard logger then the process will exit with status set to 1.
93
func Fatal(args ...interface{}) {
94
Log.Fatal(args...)
95
}
96
97
// Tracef logs a message at level Trace on the standard logger.
98
func Tracef(format string, args ...interface{}) {
99
Log.Tracef(format, args...)
100
}
101
102
// Debugf logs a message at level Debug on the standard logger.
103
func Debugf(format string, args ...interface{}) {
104
Log.Debugf(format, args...)
105
}
106
107
// Printf logs a message at level Info on the standard logger.
108
func Printf(format string, args ...interface{}) {
109
Log.Printf(format, args...)
110
}
111
112
// Infof logs a message at level Info on the standard logger.
113
func Infof(format string, args ...interface{}) {
114
Log.Infof(format, args...)
115
}
116
117
// Warnf logs a message at level Warn on the standard logger.
118
func Warnf(format string, args ...interface{}) {
119
Log.Warnf(format, args...)
120
}
121
122
// Warningf logs a message at level Warn on the standard logger.
123
func Warningf(format string, args ...interface{}) {
124
Log.Warningf(format, args...)
125
}
126
127
// Errorf logs a message at level Error on the standard logger.
128
func Errorf(format string, args ...interface{}) {
129
Log.Errorf(format, args...)
130
}
131
132
// Panicf logs a message at level Panic on the standard logger.
133
func Panicf(format string, args ...interface{}) {
134
Log.Panicf(format, args...)
135
}
136
137
// Fatalf logs a message at level Fatal on the standard logger then the process will exit with status set to 1.
138
func Fatalf(format string, args ...interface{}) {
139
Log.Fatalf(format, args...)
140
}
141
142
// Traceln logs a message at level Trace on the standard logger.
143
func Traceln(args ...interface{}) {
144
Log.Traceln(args...)
145
}
146
147
// Debugln logs a message at level Debug on the standard logger.
148
func Debugln(args ...interface{}) {
149
Log.Debugln(args...)
150
}
151
152
// Println logs a message at level Info on the standard logger.
153
func Println(args ...interface{}) {
154
Log.Println(args...)
155
}
156
157
// Infoln logs a message at level Info on the standard logger.
158
func Infoln(args ...interface{}) {
159
Log.Infoln(args...)
160
}
161
162
// Warnln logs a message at level Warn on the standard logger.
163
func Warnln(args ...interface{}) {
164
Log.Warnln(args...)
165
}
166
167
// Warningln logs a message at level Warn on the standard logger.
168
func Warningln(args ...interface{}) {
169
Log.Warningln(args...)
170
}
171
172
// Errorln logs a message at level Error on the standard logger.
173
func Errorln(args ...interface{}) {
174
Log.Errorln(args...)
175
}
176
177
// Panicln logs a message at level Panic on the standard logger.
178
func Panicln(args ...interface{}) {
179
Log.Panicln(args...)
180
}
181
182
// Fatalln logs a message at level Fatal on the standard logger then the process will exit with status set to 1.
183
func Fatalln(args ...interface{}) {
184
Log.Fatalln(args...)
185
}
186
187