Browse Source

Redirect stdout and stderr to logfile

Makes it harder to loose panic messages
pull/3579/head
Sandro Santilli 8 years ago
parent
commit
43fe389af3
  1. 5
      modules/log/file.go

5
modules/log/file.go

@ -14,6 +14,7 @@ import (
"path/filepath"
"strings"
"sync"
"syscall"
"time"
)
@ -113,6 +114,10 @@ func (w *FileLogWriter) StartLogger() error {
if err = w.initFd(); err != nil {
return err
}
// redirect stdout and stderr to file
// TODO: allow specifying in configuration ?
syscall.Dup2(int(fd.Fd()), 1) // stdout
syscall.Dup2(int(fd.Fd()), 2) // stderr
return nil
}

Loading…
Cancel
Save