]> Cypherpunks repositories - gostls13.git/commit
log: fix and cleanup trailing newline logic
authorJoe Tsai <joetsai@digital-static.net>
Sat, 4 Feb 2023 19:30:18 +0000 (11:30 -0800)
committerJoseph Tsai <joetsai@digital-static.net>
Mon, 6 Feb 2023 18:44:49 +0000 (18:44 +0000)
commite0603bc6760ee48d32a4a96a0e9cc032698d8584
tree2103b88f6350992f449c57a58f17742d70bd133c
parent677038f86625447de738831b4be9bca23929787a
log: fix and cleanup trailing newline logic

The intent was to always append a newline if a newline was missing.
The older logic accidentally only checked the payload for newlines
and forgot to check the prefix as well. Fix it to check both together.

This changes the output of Logger.Output in the situation where
the prefix contains a trailing newline and the output is empty.
This is a very rare combination and unlikely to occur in practice.

Change-Id: Ic04ded6c29a90383e29bf7f59223a808ee1cbdc0
Reviewed-on: https://go-review.googlesource.com/c/go/+/465316
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
src/log/log.go
src/log/log_test.go