Add fatal level

This commit is contained in:
Noah 2017-07-17 23:17:49 -07:00
parent 248ff19dbd
commit e5fe697fa7

View File

@ -14,6 +14,7 @@ const (
InfoLevel InfoLevel
WarnLevel WarnLevel
ErrorLevel ErrorLevel
FatalLevel
) )
// Map log levels to human readable labels. // Map log levels to human readable labels.
@ -22,6 +23,7 @@ var levelNames = map[logLevel]string{
InfoLevel: "INFO", InfoLevel: "INFO",
WarnLevel: "WARN", WarnLevel: "WARN",
ErrorLevel: "ERROR", ErrorLevel: "ERROR",
FatalLevel: "FATAL",
} }
// emit is the general purpose log line emitter. // emit is the general purpose log line emitter.
@ -30,6 +32,7 @@ func (l *Logger) emit(level logLevel, tmpl string, args ...interface{}) {
// If we have a log writer, send it there. // If we have a log writer, send it there.
if l.Config.Writer != nil { if l.Config.Writer != nil {
// TODO
// l.Config.Writer.Write(message) // l.Config.Writer.Write(message)
} else { } else {
// No writer given so we default to standard out/error. // No writer given so we default to standard out/error.
@ -68,3 +71,8 @@ func (l *Logger) Error(tmpl string, args ...interface{}) {
l.emit(ErrorLevel, tmpl, args...) l.emit(ErrorLevel, tmpl, args...)
} }
} }
// Fatal logs a fatal message and quits.
func (l *Logger) Fatal(tmpl string, args ...interface{}) {
l.emit(FatalLevel, tmpl, args...)
}