Skip to content

Commit

Permalink
fix log file issues
Browse files Browse the repository at this point in the history
fixes #32

Signed-off-by: Scott Weiss <[email protected]>
  • Loading branch information
Scott Weiss committed May 23, 2016
1 parent 43a375f commit d6cb622
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
21 changes: 11 additions & 10 deletions cmd/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,29 +45,30 @@ Example usage:
if err := readDaemonConfig(); err != nil {
return err
}
//don't print vsphere password
redactions := []string{}
for _, vsphereConfig := range daemonConfig.Providers.Vsphere {
redactions = append(redactions, vsphereConfig.VspherePassword, url.QueryEscape(vsphereConfig.VspherePassword))
}
logrus.SetFormatter(&unikutil.RedactedTextFormatter{
Redactions: redactions,
})

if debugMode {
logrus.SetLevel(logrus.DebugLevel)
}
if trace {
logrus.AddHook(&unikutil.AddTraceHook{true})
}
if logFile != "" {
f, err := os.Open(logFile)
os.Create(logFile)
f, err := os.OpenFile(logFile, os.O_WRONLY | os.O_CREATE | os.O_TRUNC, 0777)
if err != nil {
return errors.New(fmt.Sprintf("failed to open log file %s for writing", logFile), err)
}
logrus.AddHook(&unikutil.TeeHook{f})
}

//don't print vsphere password
redactions := []string{}
for _, vsphereConfig := range daemonConfig.Providers.Vsphere {
redactions = append(redactions, vsphereConfig.VspherePassword, url.QueryEscape(vsphereConfig.VspherePassword))
}
logrus.SetFormatter(&unikutil.RedactedTextFormatter{
Redactions: redactions,
})

logrus.WithField("config", daemonConfig).Info("daemon started")
d, err := daemon.NewUnikDaemon(daemonConfig)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func (h *TeeHook) Fire(entry *logrus.Entry) error {
logger.WithFields(entry.Data).Info(entry.Message)
break
case logrus.DebugLevel:
logger.WithFields(entry.Data).Debug(entry.Message)
logger.WithFields(entry.Data).Info(entry.Message)
break
}
return nil
Expand Down

0 comments on commit d6cb622

Please sign in to comment.