syslog: add Spew option.
This is a debug print that spews any arguments passed in.
This commit is contained in:
parent
74ce7bc58a
commit
9091cc7682
|
@ -7,6 +7,7 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
gsyslog "github.com/hashicorp/go-syslog"
|
||||
)
|
||||
|
||||
|
@ -52,6 +53,12 @@ func (log *logger) println(p gsyslog.Priority, args ...interface{}) {
|
|||
}
|
||||
}
|
||||
|
||||
func (log *logger) spew(args ...interface{}) {
|
||||
if log.p == gsyslog.LOG_DEBUG {
|
||||
spew.Dump(args...)
|
||||
}
|
||||
}
|
||||
|
||||
func (log *logger) adjustPriority(level string) error {
|
||||
priority, ok := priorities[level]
|
||||
if !ok {
|
||||
|
@ -252,6 +259,11 @@ func Fatalf(format string, args ...interface{}) {
|
|||
os.Exit(1)
|
||||
}
|
||||
|
||||
// Spew will pretty print the args if the logger is set to DEBUG priority.
|
||||
func Spew(args ...interface{}) {
|
||||
log.spew(args...)
|
||||
}
|
||||
|
||||
func ChangePriority(level string) error {
|
||||
return log.adjustPriority(level)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue