Skip to content

Commit

Permalink
tlflag: ?console=flags
Browse files Browse the repository at this point in the history
  • Loading branch information
nikandfor committed Sep 25, 2024
1 parent f2a2553 commit adb4950
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions ext/tlflag/flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ext/tlflag/flag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit adb4950

Please sign in to comment.