mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-10-07 11:27:50 +00:00
dup log output onto stderr to catch panics in log file
This commit is contained in:
parent
65f478470f
commit
77598c2cc6
1 changed files with 6 additions and 2 deletions
|
|
@ -176,14 +176,18 @@ func (m *Command) Wait() error {
|
|||
|
||||
// setupLogger sets up the logger based on the configuration.
|
||||
func (m *Command) setupLogger() error {
|
||||
var err error
|
||||
if m.Config.LogPath == "" {
|
||||
m.logOutput = m.Stderr
|
||||
} else {
|
||||
m.logOutput, err = os.OpenFile(m.Config.LogPath, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0600)
|
||||
f, err := os.OpenFile(m.Config.LogPath, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0600)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "opening file")
|
||||
}
|
||||
m.logOutput = f
|
||||
err = syscall.Dup2(int(f.Fd()), int(os.Stderr.Fd()))
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "dup2ing stderr onto logfile")
|
||||
}
|
||||
}
|
||||
|
||||
if m.Config.Verbose {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue