Browse Source

Redirect stdout and stderr to logfile

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

5
modules/log/file.go

@ -14,6 +14,7 @@ import (
"path/filepath" "path/filepath"
"strings" "strings"
"sync" "sync"
"syscall"
"time" "time"
) )
@ -113,6 +114,10 @@ func (w *FileLogWriter) StartLogger() error {
if err = w.initFd(); err != nil { if err = w.initFd(); err != nil {
return err 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 return nil
} }

Loading…
Cancel
Save