cmd: add --debug for debug logging
This commit is contained in:
parent
fa32839623
commit
486e898ce9
1 changed files with 6 additions and 0 deletions
|
@ -19,6 +19,11 @@ import (
|
|||
)
|
||||
|
||||
func rootCmdRun(cmd *cobra.Command, args []string) error {
|
||||
debugLog, _ := cmd.Flags().GetBool("debug")
|
||||
if debugLog {
|
||||
log.SetLevel(log.DebugLevel)
|
||||
log.Debugln("debug logging enabled")
|
||||
}
|
||||
cpuProfilePath, _ := cmd.Flags().GetString("cpuprofile")
|
||||
if cpuProfilePath != "" {
|
||||
log.Infoln("enabled CPU profiling to", cpuProfilePath)
|
||||
|
@ -149,6 +154,7 @@ func main() {
|
|||
}
|
||||
rootCmd.Flags().String("config", "/etc/chihaya.yaml", "location of configuration file")
|
||||
rootCmd.Flags().String("cpuprofile", "", "location to save a CPU profile")
|
||||
rootCmd.Flags().Bool("debug", false, "enable debug logging")
|
||||
|
||||
if err := rootCmd.Execute(); err != nil {
|
||||
log.Fatal(err)
|
||||
|
|
Loading…
Reference in a new issue