Skip to content

Commit

Permalink
log: fix duplicated LF
Browse files Browse the repository at this point in the history
  • Loading branch information
hexian000 committed Oct 24, 2023
1 parent 4339207 commit c31d154
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ var DefaultConfig = Config{
StreamWindow: 256 * 1024, // 256 KiB
RequestTimeout: 30,
WriteTimeout: 15,
Log: "stderr",
Log: "stdout",
LogLevel: slog.LevelInfo,
}

Expand Down Expand Up @@ -143,7 +143,7 @@ type logWrapper struct {

func (w *logWrapper) Write(p []byte) (n int, err error) {
const calldepth = 4
raw := string(p)
raw := strings.TrimSuffix(string(p), "\n")
if msg := strings.TrimPrefix(raw, "[ERR] "); len(msg) != len(raw) {
w.Output(calldepth, slog.LevelError, []byte(msg))
} else if msg := strings.TrimPrefix(raw, "[WARN] "); len(msg) != len(raw) {
Expand Down

0 comments on commit c31d154

Please sign in to comment.