introduce --debug flag to hide excessive error messages by default but allow displaying them

This commit is contained in:
Dominic Breuker
2019-04-24 21:42:18 +02:00
parent 7d9d32412b
commit 8a1838faee
5 changed files with 22 additions and 12 deletions

View File

@@ -58,6 +58,7 @@ var defaultRDirs = []string{
var defaultDirs = []string{}
var triggerInterval int
var colored bool
var debug bool
func init() {
rootCmd.PersistentFlags().BoolVarP(&logPS, "procevents", "p", true, "print new processes to stdout")
@@ -66,12 +67,13 @@ func init() {
rootCmd.PersistentFlags().StringArrayVarP(&dirs, "dirs", "d", defaultDirs, "watch these dirs")
rootCmd.PersistentFlags().IntVarP(&triggerInterval, "interval", "i", 100, "scan every 'interval' milliseconds for new processes")
rootCmd.PersistentFlags().BoolVarP(&colored, "color", "c", true, "color the printed events")
rootCmd.PersistentFlags().BoolVarP(&debug, "debug", "", false, "print detailed error messages")
log.SetOutput(os.Stdout)
}
func root(cmd *cobra.Command, args []string) {
logger := logging.NewLogger()
logger := logging.NewLogger(debug)
cfg := &config.Config{
RDirs: rDirs,