Fix trace level support.
Signed-off-by: Lantao Liu <lantaol@google.com>
This commit is contained in:
parent
424c0fb59d
commit
f2c585a59a
@ -2,6 +2,7 @@ package log
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"sync/atomic"
|
||||||
|
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
@ -54,14 +55,16 @@ func GetLogger(ctx context.Context) *logrus.Entry {
|
|||||||
|
|
||||||
// Trace logs a message at level Trace with the log entry passed-in.
|
// Trace logs a message at level Trace with the log entry passed-in.
|
||||||
func Trace(e *logrus.Entry, args ...interface{}) {
|
func Trace(e *logrus.Entry, args ...interface{}) {
|
||||||
if e.Level >= TraceLevel {
|
level := logrus.Level(atomic.LoadUint32((*uint32)(&e.Logger.Level)))
|
||||||
|
if level >= TraceLevel {
|
||||||
e.Debug(args...)
|
e.Debug(args...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tracef logs a message at level Trace with the log entry passed-in.
|
// Tracef logs a message at level Trace with the log entry passed-in.
|
||||||
func Tracef(e *logrus.Entry, format string, args ...interface{}) {
|
func Tracef(e *logrus.Entry, format string, args ...interface{}) {
|
||||||
if e.Level >= TraceLevel {
|
level := logrus.Level(atomic.LoadUint32((*uint32)(&e.Logger.Level)))
|
||||||
|
if level >= TraceLevel {
|
||||||
e.Debugf(format, args...)
|
e.Debugf(format, args...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user