Selaa lähdekoodia

Merge pull request #1 from mattn/fix-crash

Fix crash
Vishal Rana 10 vuotta sitten
vanhempi
commit
e1ed10edce
1 muutettua tiedostoa jossa 1 lisäystä ja 1 poistoa
  1. 1 1
      log/log.go

+ 1 - 1
log/log.go

@@ -151,7 +151,7 @@ func (l *Logger) log(v Level, w io.Writer, msg interface{}, args ...interface{})
 	l.Lock()
 	defer l.Unlock()
 	// }
-	if v >= l.level {
+	if v >= l.level && int(v) < len(levels) {
 		// TODO: Improve performance
 		f := fmt.Sprintf("%s|%s|%s\n", levels[v], l.prefix, msg)
 		fmt.Fprintf(w, f, args...)