From 5a78094b6f6daa7a39f9e0b240356e41f9915544 Mon Sep 17 00:00:00 2001 From: dearplain Date: Tue, 14 Jun 2022 10:41:12 +0800 Subject: [PATCH] fix log crash when print empty string --- log/log.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log/log.go b/log/log.go index 371f601..7317a5f 100644 --- a/log/log.go +++ b/log/log.go @@ -209,7 +209,7 @@ func (l *Logger) Output(callDepth int, level int, format string, v ...interface{ buf = append(buf, s...) - if s[len(s)-1] != '\n' { + if len(s) == 0 || s[len(s)-1] != '\n' { buf = append(buf, '\n') }