Compare commits

...

1 Commits

Author SHA1 Message Date
9091cc7682 syslog: add Spew option.
This is a debug print that spews any arguments passed in.
2023-05-04 23:40:20 -07:00

View File

@@ -7,6 +7,7 @@ import (
"strings" "strings"
"time" "time"
"github.com/davecgh/go-spew/spew"
gsyslog "github.com/hashicorp/go-syslog" 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 { func (log *logger) adjustPriority(level string) error {
priority, ok := priorities[level] priority, ok := priorities[level]
if !ok { if !ok {
@@ -252,6 +259,11 @@ func Fatalf(format string, args ...interface{}) {
os.Exit(1) 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 { func ChangePriority(level string) error {
return log.adjustPriority(level) return log.adjustPriority(level)
} }