Sfoglia il codice sorgente

Merge pull request #1 from mattn/fix-crash

Fix crash
Vishal Rana 10 anni fa
parent
commit
e1ed10edce
1 ha cambiato i file con 1 aggiunte e 1 eliminazioni
  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...)