more fine-grained log level

This commit is contained in:
ginuerzh
2022-08-18 11:34:57 +08:00
parent 052b8e9468
commit f3f3acd4e1
57 changed files with 262 additions and 242 deletions

View File

@ -61,11 +61,13 @@ func NewLogger(opts ...LoggerOption) logger.Logger {
log.SetFormatter(&logrus.JSONFormatter{
DisableHTMLEscape: true,
// PrettyPrint: true,
TimestampFormat: "2006-01-02T15:04:05.000Z07:00",
})
}
switch options.Level {
case logger.DebugLevel,
case logger.TraceLevel,
logger.DebugLevel,
logger.InfoLevel,
logger.WarnLevel,
logger.ErrorLevel,
@ -88,6 +90,16 @@ func (l *logrusLogger) WithFields(fields map[string]any) logger.Logger {
}
}
// Trace logs a message at level Trace.
func (l *logrusLogger) Trace(args ...any) {
l.log(logrus.TraceLevel, args...)
}
// Tracef logs a message at level Trace.
func (l *logrusLogger) Tracef(format string, args ...any) {
l.logf(logrus.TraceLevel, format, args...)
}
// Debug logs a message at level Debug.
func (l *logrusLogger) Debug(args ...any) {
l.log(logrus.DebugLevel, args...)

View File

@ -18,6 +18,12 @@ func (l *nopLogger) WithFields(fields map[string]any) logger.Logger {
return l
}
func (l *nopLogger) Trace(args ...any) {
}
func (l *nopLogger) Tracef(format string, args ...any) {
}
func (l *nopLogger) Debug(args ...any) {
}