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 {
|
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")
|
cpuProfilePath, _ := cmd.Flags().GetString("cpuprofile")
|
||||||
if cpuProfilePath != "" {
|
if cpuProfilePath != "" {
|
||||||
log.Infoln("enabled CPU profiling to", 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("config", "/etc/chihaya.yaml", "location of configuration file")
|
||||||
rootCmd.Flags().String("cpuprofile", "", "location to save a CPU profile")
|
rootCmd.Flags().String("cpuprofile", "", "location to save a CPU profile")
|
||||||
|
rootCmd.Flags().Bool("debug", false, "enable debug logging")
|
||||||
|
|
||||||
if err := rootCmd.Execute(); err != nil {
|
if err := rootCmd.Execute(); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
|
|
Loading…
Add table
Reference in a new issue