From adb49501b22e136df3be46b63058033ca444b197 Mon Sep 17 00:00:00 2001 From: nikandfor Date: Thu, 26 Sep 2024 01:14:08 +0200 Subject: [PATCH] tlflag: ?console=flags --- ext/tlflag/flag.go | 8 +++++--- ext/tlflag/flag_test.go | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ext/tlflag/flag.go b/ext/tlflag/flag.go index b6279fe..80ff89e 100644 --- a/ext/tlflag/flag.go +++ b/ext/tlflag/flag.go @@ -113,7 +113,7 @@ more: case ".log", "": wrap = append(wrap, func(w io.Writer, c io.Closer) (io.Writer, io.Closer, error) { ff := tlog.LstdFlags - ff = updateConsoleFlags(ff, u.RawQuery) + ff = updateConsoleFlags(ff, u.Query()) w = tlog.NewConsoleWriter(w, ff) @@ -427,8 +427,10 @@ func updateFileFlags(of int, q string) int { return of } -func updateConsoleFlags(ff int, q string) int { - for _, c := range q { +func updateConsoleFlags(ff int, q url.Values) int { + flags := q.Get("console") + + for _, c := range flags { switch c { case 'd': ff |= tlog.LdetFlags diff --git a/ext/tlflag/flag_test.go b/ext/tlflag/flag_test.go index 906bd44..50c8e1b 100644 --- a/ext/tlflag/flag_test.go +++ b/ext/tlflag/flag_test.go @@ -29,7 +29,7 @@ func TestFileWriter(t *testing.T) { tlog.NewConsoleWriter(tlog.Stderr, tlog.LstdFlags), }, w) - w, err = OpenWriter("stderr?dm,stderr?dm") + w, err = OpenWriter("stderr?console=dm,stderr?console=dm") assert.NoError(t, err) assert.Equal(t, tlio.MultiWriter{ tlog.NewConsoleWriter(tlog.Stderr, tlog.LdetFlags|tlog.Lmilliseconds),