diff options
author | Colin Cross <ccross@android.com> | 2019-03-21 16:36:33 -0700 |
---|---|---|
committer | Colin Cross <ccross@android.com> | 2019-03-21 21:17:04 -0700 |
commit | 1aeb049a5463c8c87beb8aa034c3899a2f39a893 (patch) | |
tree | 0baf13ca3fed5c454988cbf0b52bd4d94f6b955d /ui | |
parent | b98d3bcf4efd0fa32b4dcd0ef5fc395536760f4d (diff) | |
download | build_soong-1aeb049a5463c8c87beb8aa034c3899a2f39a893.tar.gz build_soong-1aeb049a5463c8c87beb8aa034c3899a2f39a893.tar.bz2 build_soong-1aeb049a5463c8c87beb8aa034c3899a2f39a893.zip |
Panic if logging is attempted after Close
Attempt to catch places where logs are truncated by panicing if
logging is attempted after Close.
Test: m nothing
Change-Id: If670f20d08832ed65b63af5589b548e9815f2f0d
Diffstat (limited to 'ui')
-rw-r--r-- | ui/logger/logger.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/ui/logger/logger.go b/ui/logger/logger.go index 58890e96..9b26ae80 100644 --- a/ui/logger/logger.go +++ b/ui/logger/logger.go @@ -180,12 +180,16 @@ func (s *stdLogger) SetOutput(path string) *stdLogger { return s } +type panicWriter struct{} + +func (panicWriter) Write([]byte) (int, error) { panic("write to panicWriter") } + // Close disables logging to the file and closes the file handle. func (s *stdLogger) Close() { s.mutex.Lock() defer s.mutex.Unlock() if s.file != nil { - s.fileLogger.SetOutput(ioutil.Discard) + s.fileLogger.SetOutput(panicWriter{}) s.file.Close() s.file = nil } |