Skip to content
Browse files

Prefix log lines with level

  • Loading branch information...
1 parent 4b549f8 commit 69a93d453fd9fd9a6d26a5418b3a939aed67b58f @edsrzf edsrzf committed Sep 11, 2012
Showing with 8 additions and 1 deletion.
  1. +8 −1 golog.go
View
9 golog.go
@@ -25,49 +25,56 @@ func NewLogger() *Logger {
func (l *Logger) Debugln(a ...interface{}) {
if l.Level <= Debug {
- // doesn't work: a = append([]interface{"DEBUG --"}, a...)
+ a = append([]interface{}{"DEBUG --"}, a...)
log.Println(a...)
}
}
func (l *Logger) Debugf(format string, a ...interface{}) {
if l.Level <= Debug {
+ a = append([]interface{}{"DEBUG --"}, a...)
log.Printf(format, a...)
}
}
func (l *Logger) Infoln(a ...interface{}) {
if l.Level <= Info {
+ a = append([]interface{}{"INFO --"}, a...)
log.Println(a...)
}
}
func (l *Logger) Infof(format string, a ...interface{}) {
if l.Level <= Info {
+ a = append([]interface{}{"INFO --"}, a...)
log.Printf(format, a...)
}
}
func (l *Logger) Warnln(a ...interface{}) {
if l.Level <= Warn {
+ a = append([]interface{}{"WARN --"}, a...)
log.Println(a...)
}
}
func (l *Logger) Warnf(format string, a ...interface{}) {
if l.Level <= Warn {
+ a = append([]interface{}{"WARN --"}, a...)
log.Printf(format, a...)
}
}
func (l *Logger) Errorln(a ...interface{}) {
if l.Level <= Error {
+ a = append([]interface{}{"ERROR --"}, a...)
log.Println(a...)
}
}
func (l *Logger) Errorf(format string, a ...interface{}) {
if l.Level <= Error {
+ a = append([]interface{}{"ERROR --"}, a...)
log.Printf(format, a...)
}
}

0 comments on commit 69a93d4

Please sign in to comment.
Something went wrong with that request. Please try again.