diff --git a/event-exporter/go.mod b/event-exporter/go.mod index ec8a7f620..d8f1fcbbb 100644 --- a/event-exporter/go.mod +++ b/event-exporter/go.mod @@ -4,7 +4,7 @@ go 1.19 require ( cloud.google.com/go/compute v1.5.0 - github.com/golang/glog v1.2.2 + github.com/golang/glog v1.2.3 github.com/google/go-cmp v0.6.0 github.com/prometheus/client_golang v1.12.1 golang.org/x/net v0.25.0 diff --git a/event-exporter/go.sum b/event-exporter/go.sum index caafe971d..6e914993d 100644 --- a/event-exporter/go.sum +++ b/event-exporter/go.sum @@ -137,8 +137,8 @@ github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7a github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/glog v1.2.2 h1:1+mZ9upx1Dh6FmUTFR1naJ77miKiXgALjWOZ3NVFPmY= -github.com/golang/glog v1.2.2/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w= +github.com/golang/glog v1.2.3 h1:oDTdz9f5VGVVNGu/Q7UXKWYsD0873HXLHdJUNBsSEKM= +github.com/golang/glog v1.2.3/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= diff --git a/event-exporter/vendor/github.com/golang/glog/glog.go b/event-exporter/vendor/github.com/golang/glog/glog.go index 8c00e737a..1b632e077 100644 --- a/event-exporter/vendor/github.com/golang/glog/glog.go +++ b/event-exporter/vendor/github.com/golang/glog/glog.go @@ -76,7 +76,7 @@ // -log_backtrace_at=gopherflakes.go:234 // A stack trace will be written to the Info log whenever execution // hits one of these statements. (Unlike with -vmodule, the ".go" -// must bepresent.) +// must be present.) // -v=0 // Enable V-leveled logging at the specified level. // -vmodule="" diff --git a/event-exporter/vendor/github.com/golang/glog/glog_file.go b/event-exporter/vendor/github.com/golang/glog/glog_file.go index 8eb8b08c6..2b478ae64 100644 --- a/event-exporter/vendor/github.com/golang/glog/glog_file.go +++ b/event-exporter/vendor/github.com/golang/glog/glog_file.go @@ -158,7 +158,10 @@ var sinks struct { func init() { // Register stderr first: that way if we crash during file-writing at least // the log will have gone somewhere. - logsink.TextSinks = append(logsink.TextSinks, &sinks.stderr, &sinks.file) + if shouldRegisterStderrSink() { + logsink.TextSinks = append(logsink.TextSinks, &sinks.stderr) + } + logsink.TextSinks = append(logsink.TextSinks, &sinks.file) sinks.file.flushChan = make(chan logsink.Severity, 1) go sinks.file.flushDaemon() diff --git a/event-exporter/vendor/github.com/golang/glog/glog_file_nonwindows.go b/event-exporter/vendor/github.com/golang/glog/glog_file_nonwindows.go index d5cdb793c..a0089ba4a 100644 --- a/event-exporter/vendor/github.com/golang/glog/glog_file_nonwindows.go +++ b/event-exporter/vendor/github.com/golang/glog/glog_file_nonwindows.go @@ -4,6 +4,13 @@ package glog import "os/user" +// shouldRegisterStderrSink determines whether we should register a log sink that writes to stderr. +// Today, this always returns true on non-Windows platforms, as it specifically checks for a +// condition that is only present on Windows. +func shouldRegisterStderrSink() bool { + return true +} + func lookupUser() string { if current, err := user.Current(); err == nil { return current.Username diff --git a/event-exporter/vendor/github.com/golang/glog/glog_file_windows.go b/event-exporter/vendor/github.com/golang/glog/glog_file_windows.go index a9e4f609d..2f032e19b 100644 --- a/event-exporter/vendor/github.com/golang/glog/glog_file_windows.go +++ b/event-exporter/vendor/github.com/golang/glog/glog_file_windows.go @@ -3,9 +3,22 @@ package glog import ( + "os" "syscall" ) +// shouldRegisterStderrSink determines whether we should register a log sink that writes to stderr. +// Today, this checks if stderr is "valid", in that it maps to a non-NULL Handle. +// Windows Services are spawned without Stdout and Stderr, so any attempt to use them equates to +// referencing an invalid file Handle. +// os.Stderr's FD is derived from a call to `syscall.GetStdHandle(syscall.STD_ERROR_HANDLE)`. +// Documentation[1] for the GetStdHandle function indicates the return value may be NULL if the +// application lacks the standard handle, so consider Stderr valid if its FD is non-NULL. +// [1]: https://learn.microsoft.com/en-us/windows/console/getstdhandle +func shouldRegisterStderrSink() bool { + return os.Stderr.Fd() != 0 +} + // This follows the logic in the standard library's user.Current() function, except // that it leaves out the potentially expensive calls required to look up the user's // display name in Active Directory. diff --git a/event-exporter/vendor/modules.txt b/event-exporter/vendor/modules.txt index 479b88138..ac295f912 100644 --- a/event-exporter/vendor/modules.txt +++ b/event-exporter/vendor/modules.txt @@ -17,7 +17,7 @@ github.com/go-logr/logr ## explicit; go 1.15 github.com/gogo/protobuf/proto github.com/gogo/protobuf/sortkeys -# github.com/golang/glog v1.2.2 +# github.com/golang/glog v1.2.3 ## explicit; go 1.19 github.com/golang/glog github.com/golang/glog/internal/logsink