feat(logging): add -log-to-file and don't output to file by default (#1209)
* feat(logging): add -log-to-file and don't output to file by default * update go-cve-dict * fix lint err
This commit is contained in:
		@@ -42,6 +42,7 @@ func (*TuiCmd) Usage() string {
 | 
			
		||||
		[-ignore-unscored-cves]
 | 
			
		||||
		[-ignore-unfixed]
 | 
			
		||||
		[-results-dir=/path/to/results]
 | 
			
		||||
		[-log-to-file]
 | 
			
		||||
		[-log-dir=/path/to/log]
 | 
			
		||||
		[-debug]
 | 
			
		||||
		[-debug-sql]
 | 
			
		||||
@@ -63,6 +64,7 @@ func (p *TuiCmd) SetFlags(f *flag.FlagSet) {
 | 
			
		||||
 | 
			
		||||
	defaultLogDir := logging.GetDefaultLogDir()
 | 
			
		||||
	f.StringVar(&config.Conf.LogDir, "log-dir", defaultLogDir, "/path/to/log")
 | 
			
		||||
	f.BoolVar(&config.Conf.LogToFile, "log-to-file", false, "Output log to file")
 | 
			
		||||
 | 
			
		||||
	wd, _ := os.Getwd()
 | 
			
		||||
	defaultResultsDir := filepath.Join(wd, "results")
 | 
			
		||||
@@ -101,7 +103,7 @@ func (p *TuiCmd) SetFlags(f *flag.FlagSet) {
 | 
			
		||||
 | 
			
		||||
// Execute execute
 | 
			
		||||
func (p *TuiCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{}) subcommands.ExitStatus {
 | 
			
		||||
	logging.Log = logging.NewCustomLogger(config.Conf.Debug, config.Conf.Quiet, config.Conf.LogDir, "", "")
 | 
			
		||||
	logging.Log = logging.NewCustomLogger(config.Conf.Debug, config.Conf.Quiet, config.Conf.LogToFile, config.Conf.LogDir, "", "")
 | 
			
		||||
	logging.Log.Infof("vuls-%s-%s", config.Version, config.Revision)
 | 
			
		||||
	if err := config.Load(p.configPath, ""); err != nil {
 | 
			
		||||
		logging.Log.Errorf("Error loading %s, err: %+v", p.configPath, err)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user