No warning(s) in the output file with -quiet option. Report command (#885)
This commit is contained in:
@@ -44,7 +44,6 @@ func init() {
|
||||
func NewCustomLogger(c config.ServerInfo) *logrus.Entry {
|
||||
log := logrus.New()
|
||||
log.Formatter = &formatter.TextFormatter{MsgAnsiColor: c.LogMsgAnsiColor}
|
||||
log.Out = os.Stderr
|
||||
log.Level = logrus.InfoLevel
|
||||
if config.Conf.Debug {
|
||||
log.Level = logrus.DebugLevel
|
||||
@@ -62,6 +61,18 @@ func NewCustomLogger(c config.ServerInfo) *logrus.Entry {
|
||||
}
|
||||
}
|
||||
|
||||
// Only log to a file if quiet mode enabled
|
||||
if config.Conf.Quiet {
|
||||
logFile := logDir + "/vuls.log"
|
||||
if file, err := os.OpenFile(logFile, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0644); err == nil {
|
||||
log.Out = file
|
||||
} else {
|
||||
log.Errorf("Failed to create log file. path: %s, err: %s", logFile, err)
|
||||
}
|
||||
} else {
|
||||
log.Out = os.Stderr
|
||||
}
|
||||
|
||||
whereami := "localhost"
|
||||
if 0 < len(c.ServerName) {
|
||||
whereami = c.GetServerName()
|
||||
|
||||
Reference in New Issue
Block a user