checkpoint
This commit is contained in:
@@ -5,5 +5,5 @@ go_library(
|
||||
srcs = ["logger.go"],
|
||||
importpath = "git.wntrmute.dev/kyle/kdhcp/log",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = ["@com_github_hashicorp_go_syslog//:go-syslog"],
|
||||
deps = ["//bazel-kdhcp/external/com_github_hashicorp_go_syslog:go-syslog"],
|
||||
)
|
||||
|
||||
@@ -2,6 +2,8 @@ package log
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
gsyslog "github.com/hashicorp/go-syslog"
|
||||
@@ -13,6 +15,10 @@ type logger struct {
|
||||
}
|
||||
|
||||
func (log *logger) printf(p gsyslog.Priority, format string, args ...interface{}) {
|
||||
if !strings.HasSuffix(format, "\n") {
|
||||
format += "\n"
|
||||
}
|
||||
|
||||
if p <= log.p {
|
||||
fmt.Printf("%s [%s] ", prioritiev[p], timestamp())
|
||||
fmt.Printf(format, args...)
|
||||
@@ -158,34 +164,45 @@ func Emergln(args ...interface{}) {
|
||||
log.println(gsyslog.LOG_EMERG, args...)
|
||||
}
|
||||
|
||||
func Debugf(args ...interface{}) {
|
||||
log.printf(gsyslog.LOG_DEBUG, args...)
|
||||
func Debugf(format string, args ...interface{}) {
|
||||
log.printf(gsyslog.LOG_DEBUG, format, args...)
|
||||
}
|
||||
|
||||
func Infof(args ...interface{}) {
|
||||
log.printf(gsyslog.LOG_INFO, args...)
|
||||
func Infof(format string, args ...interface{}) {
|
||||
log.printf(gsyslog.LOG_INFO, format, args...)
|
||||
}
|
||||
|
||||
func Noticef(args ...interface{}) {
|
||||
log.printf(gsyslog.LOG_NOTICE, args...)
|
||||
func Noticef(format string, args ...interface{}) {
|
||||
log.printf(gsyslog.LOG_NOTICE, format, args...)
|
||||
}
|
||||
|
||||
func Warningf(args ...interface{}) {
|
||||
log.print(gsyslog.LOG_WARNING, args...)
|
||||
func Warningf(format string, args ...interface{}) {
|
||||
log.printf(gsyslog.LOG_WARNING, format, args...)
|
||||
}
|
||||
|
||||
func Errf(args ...interface{}) {
|
||||
log.printf(gsyslog.LOG_ERR, args...)
|
||||
func Errf(format string, args ...interface{}) {
|
||||
log.printf(gsyslog.LOG_ERR, format, args...)
|
||||
}
|
||||
|
||||
func Critf(args ...interface{}) {
|
||||
log.printf(gsyslog.LOG_CRIT, args...)
|
||||
func Critf(format string, args ...interface{}) {
|
||||
log.printf(gsyslog.LOG_CRIT, format, args...)
|
||||
}
|
||||
|
||||
func Alertf(args ...interface{}) {
|
||||
log.printf(gsyslog.LOG_ALERT, args...)
|
||||
func Alertf(format string, args ...interface{}) {
|
||||
log.printf(gsyslog.LOG_ALERT, format, args...)
|
||||
}
|
||||
|
||||
func Emergf(args ...interface{}) {
|
||||
log.printf(gsyslog.LOG_EMERG, args...)
|
||||
func Emergf(format string, args ...interface{}) {
|
||||
log.printf(gsyslog.LOG_EMERG, format, args...)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
func Fatal(args ...interface{}) {
|
||||
log.println(gsyslog.LOG_ERR, args...)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
func Fatalf(format string, args ...interface{}) {
|
||||
log.printf(gsyslog.LOG_ERR, format, args...)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user