aboutsummaryrefslogtreecommitdiff
path: root/go/glog/glog.go
diff options
context:
space:
mode:
authorchrislusf <chris.lu@gmail.com>2015-04-15 18:02:02 -0700
committerchrislusf <chris.lu@gmail.com>2015-04-15 18:02:02 -0700
commit2a7972e8ea7b19d0cc09f88b5fc53b94bbc25f75 (patch)
tree66f763eed83af5c09f5c9e6e66fe08bd9dac0c31 /go/glog/glog.go
parent7cc1f473b6b5c6952c9ac1c52660133c0c36f859 (diff)
downloadseaweedfs-2a7972e8ea7b19d0cc09f88b5fc53b94bbc25f75.tar.xz
seaweedfs-2a7972e8ea7b19d0cc09f88b5fc53b94bbc25f75.zip
Avoid system exit if only logging failed.
Diffstat (limited to 'go/glog/glog.go')
-rw-r--r--go/glog/glog.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/go/glog/glog.go b/go/glog/glog.go
index f8a14650b..fb55c0356 100644
--- a/go/glog/glog.go
+++ b/go/glog/glog.go
@@ -445,6 +445,10 @@ type loggingT struct {
// safely using atomic.LoadInt32.
vmodule moduleSpec // The state of the -vmodule flag.
verbosity Level // V logging level, the value of the -v flag/
+
+ // If the logging exits, the system should still run.
+ // This flag is to disable the logging if logging exited.
+ exited bool
}
// buffer holds a byte Buffer for reuse. The zero value is ready for use.
@@ -743,7 +747,7 @@ func (l *loggingT) exit(err error) {
return
}
l.flushAll()
- os.Exit(2)
+ l.exited = true // os.Exit(2)
}
// syncBuffer joins a bufio.Writer to its underlying file, providing access to the
@@ -763,6 +767,9 @@ func (sb *syncBuffer) Sync() error {
}
func (sb *syncBuffer) Write(p []byte) (n int, err error) {
+ if sb.logger.exited {
+ return
+ }
if sb.nbytes+uint64(len(p)) >= MaxSize {
if err := sb.rotateFile(time.Now()); err != nil {
sb.logger.exit(err)