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
diff --git a/ui/logger/logger.go b/ui/logger/logger.go
index 58890e9..9b26ae8 100644
--- a/ui/logger/logger.go
+++ b/ui/logger/logger.go
@@ -180,12 +180,16 @@
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
}