From 74c75878702536a6552f9427e1df7786554dd492 Mon Sep 17 00:00:00 2001 From: Naoki Kosaka Date: Fri, 17 Sep 2021 09:30:54 +0900 Subject: [PATCH] Add debug log level. --- main.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/main.go b/main.go index 7fef5b8..35b8779 100644 --- a/main.go +++ b/main.go @@ -54,6 +54,7 @@ import ( var ( version string + verbose bool globalConfig *models.RelayConfig ) @@ -65,6 +66,7 @@ func main() { var app = buildCommand() app.PersistentFlags().StringP("config", "c", "config.yml", "Path of config file.") + app.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "Show debug log in stdout.") app.Execute() } @@ -119,6 +121,11 @@ func buildCommand() *cobra.Command { } func initConfig(cmd *cobra.Command) { + if verbose { + logrus.SetLevel(logrus.DebugLevel) + fmt.Println("DEBUG VIEW") + } + configPath := cmd.Flag("config").Value.String() file, err := os.Open(configPath) defer file.Close()