From 47aecbccf9733d3c12df698da7dffdc267e0b48d Mon Sep 17 00:00:00 2001 From: Takuto Ikuta Date: Wed, 16 Apr 2025 15:38:14 +0900 Subject: [PATCH 1/2] Use Fatal severity if glog exits due to write failure Without this, our program exited without any message when there are some disk write error (e.g. no space on device). By increasing the severity, we can notice what caused the program exited as the log will be shown on stderr. --- glog.go | 1 + 1 file changed, 1 insertion(+) diff --git a/glog.go b/glog.go index 1b632e07..8d4858c3 100644 --- a/glog.go +++ b/glog.go @@ -247,6 +247,7 @@ func sinkf(meta *logsink.Meta, format string, args ...any) { } if err != nil { + meta.Severity = logsinc.Fatal logsink.Printf(meta, "glog: exiting because of error: %s", err) sinks.file.Flush() os.Exit(2) From 34298a0a6288815bb2959ace129b70cbc74c5fe5 Mon Sep 17 00:00:00 2001 From: Takuto Ikuta Date: Thu, 24 Apr 2025 09:41:50 +0900 Subject: [PATCH 2/2] Update glog.go --- glog.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/glog.go b/glog.go index 8d4858c3..f265bbc3 100644 --- a/glog.go +++ b/glog.go @@ -247,10 +247,7 @@ func sinkf(meta *logsink.Meta, format string, args ...any) { } if err != nil { - meta.Severity = logsinc.Fatal - logsink.Printf(meta, "glog: exiting because of error: %s", err) - sinks.file.Flush() - os.Exit(2) + Fatalf("glog: exiting because of error writing previous log to sinks: %v", err) } }