|
32 | 32 | RemoteTendermintRpc string
|
33 | 33 | BinaryPath string
|
34 | 34 | LogLevel string
|
| 35 | + JsonOutput bool |
35 | 36 |
|
36 | 37 | GithubOrg string
|
37 | 38 | GithubRepo string
|
@@ -63,15 +64,11 @@ var rootCmd = &cobra.Command{
|
63 | 64 | Long: "Scrape the data on Tendermint node.",
|
64 | 65 | PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
|
65 | 66 | if ConfigPath == "" {
|
66 |
| - log.Info().Msg("Config file not provided") |
67 | 67 | return nil
|
68 | 68 | }
|
69 | 69 |
|
70 |
| - log.Info().Msg("Config file provided") |
71 |
| - |
72 | 70 | viper.SetConfigFile(ConfigPath)
|
73 | 71 | if err := viper.ReadInConfig(); err != nil {
|
74 |
| - log.Info().Err(err).Msg("Error reading config file") |
75 | 72 | if _, ok := err.(viper.ConfigFileNotFoundError); !ok {
|
76 | 73 | return err
|
77 | 74 | }
|
@@ -100,6 +97,10 @@ func Execute(cmd *cobra.Command, args []string) {
|
100 | 97 |
|
101 | 98 | zerolog.SetGlobalLevel(logLevel)
|
102 | 99 |
|
| 100 | + if JsonOutput { |
| 101 | + log = zerolog.New(os.Stdout).With().Timestamp().Logger() |
| 102 | + } |
| 103 | + |
103 | 104 | http.HandleFunc("/metrics", Handler)
|
104 | 105 |
|
105 | 106 | log.Info().Str("address", ListenAddress).Msg("Listening")
|
@@ -409,6 +410,7 @@ func main() {
|
409 | 410 | rootCmd.PersistentFlags().StringVar(&GithubOrg, "github-org", "", "Github organization name")
|
410 | 411 | rootCmd.PersistentFlags().StringVar(&GithubRepo, "github-repo", "", "Github repository name")
|
411 | 412 | rootCmd.PersistentFlags().StringVar(&GithubToken, "github-token", "", "Github personal access token")
|
| 413 | + rootCmd.PersistentFlags().BoolVar(&JsonOutput, "json", false, "Output logs as JSON") |
412 | 414 |
|
413 | 415 | if err := rootCmd.Execute(); err != nil {
|
414 | 416 | log.Fatal().Err(err).Msg("Could not start application")
|
|
0 commit comments