1
0

Added Reopen() method for Logger.

This commit is contained in:
Alexander Andreev 2022-05-24 23:33:37 +04:00
parent 60dcf2c11c
commit ec06099d89
Signed by: Arav
GPG Key ID: 0388CC8FAA51063F

View File

@ -28,6 +28,17 @@ func NewLogger(path string, toStdout bool) (*Logger, error) {
return &Logger{file: f, toStdout: toStdout}, nil
}
func (l *Logger) Reopen(path string) error {
f, err := os.OpenFile(path, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0660)
if err != nil {
return err
}
l.file.Close()
l.file = f
return nil
}
func (l *Logger) Println(v ...interface{}) {
l.mut.Lock()
defer l.mut.Unlock()