diff --git a/syslog/logger.go b/syslog/logger.go index f7f2f78..8a427e2 100644 --- a/syslog/logger.go +++ b/syslog/logger.go @@ -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) }