mirror of
https://github.com/tuna/tunasync.git
synced 2025-06-14 13:32:43 +00:00
Add a debugging log level to tunasynctl
This commit is contained in:
parent
91209cab60
commit
b132192448
@ -32,7 +32,7 @@ const (
|
||||
userCfgFile = "$HOME/.config/tunasync/ctl.conf" // user-specific conf
|
||||
)
|
||||
|
||||
var logger = logging.MustGetLogger("tunasynctl-cmd")
|
||||
var logger = logging.MustGetLogger("tunasynctl")
|
||||
|
||||
var baseURL string
|
||||
var client *http.Client
|
||||
@ -67,7 +67,7 @@ func loadConfig(cfgFile string, cfg *config) error {
|
||||
|
||||
func initialize(c *cli.Context) error {
|
||||
// init logger
|
||||
tunasync.InitLogger(c.Bool("verbose"), c.Bool("verbose"), false)
|
||||
tunasync.InitLogger(c.Bool("verbose"), c.Bool("debug"), false)
|
||||
|
||||
cfg := new(config)
|
||||
|
||||
@ -79,6 +79,7 @@ func initialize(c *cli.Context) error {
|
||||
if _, err := os.Stat(systemCfgFile); err == nil {
|
||||
loadConfig(systemCfgFile, cfg)
|
||||
}
|
||||
logger.Debug("user config file: %s", os.ExpandEnv(userCfgFile))
|
||||
if _, err := os.Stat(os.ExpandEnv(userCfgFile)); err == nil {
|
||||
loadConfig(os.ExpandEnv(userCfgFile), cfg)
|
||||
}
|
||||
@ -462,6 +463,10 @@ func main() {
|
||||
Name: "verbose, v",
|
||||
Usage: "Enable verbosely logging",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "debug",
|
||||
Usage: "Enable debugging logging",
|
||||
},
|
||||
}
|
||||
cmdFlags := []cli.Flag{
|
||||
cli.StringFlag{
|
||||
|
@ -24,12 +24,12 @@ func InitLogger(verbose, debug, withSystemd bool) {
|
||||
|
||||
if debug {
|
||||
logging.SetLevel(logging.DEBUG, "tunasync")
|
||||
logging.SetLevel(logging.DEBUG, "tunasynctl-cmd")
|
||||
logging.SetLevel(logging.DEBUG, "tunasynctl")
|
||||
} else if verbose {
|
||||
logging.SetLevel(logging.INFO, "tunasync")
|
||||
logging.SetLevel(logging.INFO, "tunasynctl-cmd")
|
||||
logging.SetLevel(logging.INFO, "tunasynctl")
|
||||
} else {
|
||||
logging.SetLevel(logging.NOTICE, "tunasync")
|
||||
logging.SetLevel(logging.NOTICE, "tunasynctl-cmd")
|
||||
logging.SetLevel(logging.NOTICE, "tunasynctl")
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user