update logger package for new level 'notice'

This commit is contained in:
Ethan Buchman
2015-07-19 22:43:58 +00:00
parent 95765db7eb
commit e087284a4f
7 changed files with 26 additions and 6 deletions
+3 -1
View File
@@ -52,8 +52,10 @@ func TerminalFormat() Format {
color = 31
case LvlWarn:
color = 33
case LvlInfo:
case LvlNotice:
color = 32
case LvlInfo:
color = 34
case LvlDebug:
color = 36
}
+10
View File
@@ -17,6 +17,7 @@ const (
LvlCrit Lvl = iota
LvlError
LvlWarn
LvlNotice
LvlInfo
LvlDebug
)
@@ -28,6 +29,8 @@ func (l Lvl) String() string {
return "dbug"
case LvlInfo:
return "info"
case LvlNotice:
return "notice"
case LvlWarn:
return "warn"
case LvlError:
@@ -47,6 +50,8 @@ func LvlFromString(lvlString string) (Lvl, error) {
return LvlDebug, nil
case "info":
return LvlInfo, nil
case "notice":
return LvlNotice, nil
case "warn":
return LvlWarn, nil
case "error", "eror":
@@ -85,6 +90,7 @@ type Logger interface {
// Log a message at the given level with context key/value pairs
Debug(msg string, ctx ...interface{})
Info(msg string, ctx ...interface{})
Notice(msg string, ctx ...interface{})
Warn(msg string, ctx ...interface{})
Error(msg string, ctx ...interface{})
Crit(msg string, ctx ...interface{})
@@ -133,6 +139,10 @@ func (l *logger) Info(msg string, ctx ...interface{}) {
l.write(msg, LvlInfo, ctx)
}
func (l *logger) Notice(msg string, ctx ...interface{}) {
l.write(msg, LvlNotice, ctx)
}
func (l *logger) Warn(msg string, ctx ...interface{}) {
l.write(msg, LvlWarn, ctx)
}
+5
View File
@@ -51,6 +51,11 @@ func Info(msg string, ctx ...interface{}) {
root.write(msg, LvlInfo, ctx)
}
// Notice is a convenient alias for Root().Notice
func Notice(msg string, ctx ...interface{}) {
root.write(msg, LvlNotice, ctx)
}
// Warn is a convenient alias for Root().Warn
func Warn(msg string, ctx ...interface{}) {
root.write(msg, LvlWarn, ctx)
+2
View File
@@ -34,6 +34,8 @@ func sharedSyslog(fmtr Format, sysWr *syslog.Writer, err error) (Handler, error)
syslogFn = sysWr.Err
case LvlWarn:
syslogFn = sysWr.Warning
case LvlNotice:
syslogFn = sysWr.Notice
case LvlInfo:
syslogFn = sysWr.Info
case LvlDebug: