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