Add TRACE level logging
This commit is contained in:
parent
719bd98544
commit
bba72ee161
4 changed files with 19 additions and 2 deletions
|
@ -227,6 +227,7 @@ func setup() {
|
|||
if opts.Logging.Level != "" {
|
||||
|
||||
chk = map[string]bool{
|
||||
"trace": true,
|
||||
"debug": true,
|
||||
"info": true,
|
||||
"warn": true,
|
||||
|
|
|
@ -45,6 +45,8 @@ func (h *DefaultHook) Fire(entry *logrus.Entry) error {
|
|||
// SetLevel sets the logging level of the logger instance.
|
||||
func (h *DefaultHook) SetLevel(v string) {
|
||||
switch v {
|
||||
case "trace":
|
||||
h.l = TraceLevels
|
||||
case "debug":
|
||||
h.l = DebugLevels
|
||||
case "info":
|
||||
|
|
12
log/log.go
12
log/log.go
|
@ -28,6 +28,7 @@ const (
|
|||
WarnLevel = logrus.WarnLevel
|
||||
InfoLevel = logrus.InfoLevel
|
||||
DebugLevel = logrus.DebugLevel
|
||||
TraceLevel = logrus.TraceLevel
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -64,6 +65,15 @@ var (
|
|||
InfoLevel,
|
||||
DebugLevel,
|
||||
}
|
||||
TraceLevels = []logrus.Level{
|
||||
PanicLevel,
|
||||
FatalLevel,
|
||||
ErrorLevel,
|
||||
WarnLevel,
|
||||
InfoLevel,
|
||||
DebugLevel,
|
||||
TraceLevel,
|
||||
}
|
||||
)
|
||||
|
||||
var log *Logger
|
||||
|
@ -77,7 +87,7 @@ func init() {
|
|||
log = &Logger{
|
||||
&logrus.Logger{
|
||||
Out: ioutil.Discard,
|
||||
Level: logrus.DebugLevel,
|
||||
Level: logrus.TraceLevel,
|
||||
Hooks: logrus.LevelHooks{},
|
||||
Formatter: &logrus.TextFormatter{},
|
||||
},
|
||||
|
|
|
@ -126,8 +126,12 @@ func (f *TextFormatter) printColored(b *bytes.Buffer, entry *logrus.Entry, keys
|
|||
var prefix string
|
||||
|
||||
switch entry.Level {
|
||||
case logrus.TraceLevel:
|
||||
color = ansi.White
|
||||
case logrus.DebugLevel:
|
||||
color = ansi.Magenta
|
||||
case logrus.InfoLevel:
|
||||
color = ansi.Green
|
||||
color = ansi.Blue
|
||||
case logrus.WarnLevel:
|
||||
color = ansi.Yellow
|
||||
case logrus.ErrorLevel:
|
||||
|
|
Loading…
Reference in a new issue