[exp] slog: accept UTC times

72 views
Skip to first unread message

Jonathan Amsterdam (Gerrit)

unread,
Sep 9, 2022, 10:53:06 AM9/9/22
to goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Alan Donovan, Gopher Robot, golang-co...@googlegroups.com

Jonathan Amsterdam submitted this change.

View Change


Approvals: Jonathan Amsterdam: Run TryBots Alan Donovan: Looks good to me, approved Gopher Robot: TryBots succeeded
slog: accept UTC times and Windows drive letters

The regexp that matches the current time in tests now accepts a "Z"
timezone designator. Previously it assumed that the timezone was
formatted as an offset from UTC.

The regexp that matched a source pathname now accepts an optional
intial drive letter and colon, for Windows compatibility.

Change-Id: I17dfae16e08cae0291abe90216ed25c61750dffb
Reviewed-on: https://go-review.googlesource.com/c/exp/+/429836
Run-TryBot: Jonathan Amsterdam <j...@google.com>
Reviewed-by: Alan Donovan <adon...@google.com>
TryBot-Result: Gopher Robot <go...@golang.org>
---
M slog/logger_test.go
M slog/text_handler_test.go
2 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/slog/logger_test.go b/slog/logger_test.go
index acee8d5..f6fcb16 100644
--- a/slog/logger_test.go
+++ b/slog/logger_test.go
@@ -16,7 +16,7 @@
"time"
)

-const timeRE = `\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}-\d{2}:\d{2}`
+const timeRE = `\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}(Z|-\d{2}:\d{2})`

func TestLogTextHandler(t *testing.T) {
var buf bytes.Buffer
diff --git a/slog/text_handler_test.go b/slog/text_handler_test.go
index a7d2602..4d40742 100644
--- a/slog/text_handler_test.go
+++ b/slog/text_handler_test.go
@@ -97,7 +97,7 @@
t.Fatal(err)
}
got := buf.String()
- wantRE := `source=[^:]+text_handler_test\.go:\d+ msg`
+ wantRE := `source=([A-Z]:)?[^:]+text_handler_test\.go:\d+ msg`
matched, err := regexp.MatchString(wantRE, got)
if err != nil {
t.Fatal(err)

To view, visit change 429836. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: exp
Gerrit-Branch: master
Gerrit-Change-Id: I17dfae16e08cae0291abe90216ed25c61750dffb
Gerrit-Change-Number: 429836
Gerrit-PatchSet: 4
Gerrit-Owner: Jonathan Amsterdam <j...@google.com>
Gerrit-Reviewer: Alan Donovan <adon...@google.com>
Gerrit-Reviewer: Gopher Robot <go...@golang.org>
Gerrit-Reviewer: Jonathan Amsterdam <j...@google.com>
Gerrit-MessageType: merged
Reply all
Reply to author
Forward
0 new messages