summaryrefslogtreecommitdiffstats
path: root/modules/log/log.go
diff options
context:
space:
mode:
Diffstat (limited to 'modules/log/log.go')
-rw-r--r--modules/log/log.go37
1 files changed, 37 insertions, 0 deletions
diff --git a/modules/log/log.go b/modules/log/log.go
index 71e88491f1..2a35b5752c 100644
--- a/modules/log/log.go
+++ b/modules/log/log.go
@@ -5,6 +5,7 @@
package log
import (
+ "fmt"
"os"
"runtime"
"strings"
@@ -192,6 +193,42 @@ func IsFatal() bool {
return GetLevel() <= FATAL
}
+// Pause pauses all the loggers
+func Pause() {
+ NamedLoggers.Range(func(key, value interface{}) bool {
+ logger := value.(*Logger)
+ logger.Pause()
+ logger.Flush()
+ return true
+ })
+}
+
+// Resume resumes all the loggers
+func Resume() {
+ NamedLoggers.Range(func(key, value interface{}) bool {
+ logger := value.(*Logger)
+ logger.Resume()
+ return true
+ })
+}
+
+// ReleaseReopen releases and reopens logging files
+func ReleaseReopen() error {
+ var accumulatedErr error
+ NamedLoggers.Range(func(key, value interface{}) bool {
+ logger := value.(*Logger)
+ if err := logger.ReleaseReopen(); err != nil {
+ if accumulatedErr == nil {
+ accumulatedErr = fmt.Errorf("Error reopening %s: %v", key.(string), err)
+ } else {
+ accumulatedErr = fmt.Errorf("Error reopening %s: %v & %v", key.(string), err, accumulatedErr)
+ }
+ }
+ return true
+ })
+ return accumulatedErr
+}
+
// Close closes all the loggers
func Close() {
l, ok := NamedLoggers.Load(DEFAULT)