Added Reopen() method for Logger.
This commit is contained in:
parent
09eaecd8ed
commit
bf189d050a
@ -28,6 +28,17 @@ func NewLogger(path string, toStdout bool) (*Logger, error) {
|
|||||||
return &Logger{file: f, toStdout: toStdout}, nil
|
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{}) {
|
func (l *Logger) Println(v ...interface{}) {
|
||||||
l.mut.Lock()
|
l.mut.Lock()
|
||||||
defer l.mut.Unlock()
|
defer l.mut.Unlock()
|
||||||
|
Loading…
Reference in New Issue
Block a user