summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Pratt <mpratt@google.com>2023-04-12 11:56:14 -0400
committerGopher Robot <gobot@golang.org>2023-04-12 16:09:24 +0000
commitebc13fb0b83341a444f55cf226f786fdc9782018 (patch)
tree9ae89cd8eb2d575c33879eb751ddb1d96dde7b10
parentd91d8325308a8ad6943bd46ab3396ae8decd8348 (diff)
downloadgo-git-ebc13fb0b83341a444f55cf226f786fdc9782018.tar.gz
log/syslog: report hostname mismatch error details
The existing error log in check doesn't report the got/want hostname even though that can be the cause of the error. Log those as well. While we're here, also report os.Hostname() errors. For #59568. Change-Id: Ia277f85eddc541f2e78d719bc731db24e4513754 Reviewed-on: https://go-review.googlesource.com/c/go/+/483915 Run-TryBot: Michael Pratt <mpratt@google.com> Auto-Submit: Michael Pratt <mpratt@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com>
-rw-r--r--src/log/syslog/syslog_test.go7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/log/syslog/syslog_test.go b/src/log/syslog/syslog_test.go
index c7a5bfbd7b..cec225f751 100644
--- a/src/log/syslog/syslog_test.go
+++ b/src/log/syslog/syslog_test.go
@@ -270,7 +270,7 @@ func TestDial(t *testing.T) {
func check(t *testing.T, in, out, transport string) {
hostname, err := os.Hostname()
if err != nil {
- t.Error("Error retrieving hostname")
+ t.Errorf("Error retrieving hostname: %v", err)
return
}
@@ -290,9 +290,12 @@ func check(t *testing.T, in, out, transport string) {
var pid int
tmpl := fmt.Sprintf("<%d>%%s %%s syslog_test[%%d]: %s\n", LOG_USER+LOG_INFO, in)
n, err := fmt.Sscanf(out, tmpl, &timestamp, &parsedHostname, &pid)
- if n != 3 || err != nil || hostname != parsedHostname {
+ if n != 3 || err != nil {
t.Errorf("Got %q, does not match template %q (%d %s)", out, tmpl, n, err)
}
+ if hostname != parsedHostname {
+ t.Errorf("Hostname got %q want %q in %q", parsedHostname, hostname, out)
+ }
}
func TestWrite(t *testing.T) {