syslog: add Spew option.

This is a debug print that spews any arguments passed in.
This commit is contained in:
Kyle Isom 2023-05-04 23:40:20 -07:00
parent 74ce7bc58a
commit 9091cc7682
1 changed files with 12 additions and 0 deletions

View File

@ -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)
}