mirror of
https://github.com/tuna/tunasync.git
synced 2025-04-20 20:22:46 +00:00
Merge pull request #112 from BITNP/cli-logging
Use proper logging for some debug output
This commit is contained in:
commit
d10387e40b
@ -55,6 +55,7 @@ type config struct {
|
|||||||
|
|
||||||
func loadConfig(cfgFile string, cfg *config) error {
|
func loadConfig(cfgFile string, cfg *config) error {
|
||||||
if cfgFile != "" {
|
if cfgFile != "" {
|
||||||
|
logger.Infof("Loading config: %s", cfgFile)
|
||||||
if _, err := toml.DecodeFile(cfgFile, cfg); err != nil {
|
if _, err := toml.DecodeFile(cfgFile, cfg); err != nil {
|
||||||
logger.Errorf(err.Error())
|
logger.Errorf(err.Error())
|
||||||
return err
|
return err
|
||||||
@ -78,7 +79,6 @@ func initialize(c *cli.Context) error {
|
|||||||
if _, err := os.Stat(systemCfgFile); err == nil {
|
if _, err := os.Stat(systemCfgFile); err == nil {
|
||||||
loadConfig(systemCfgFile, cfg)
|
loadConfig(systemCfgFile, cfg)
|
||||||
}
|
}
|
||||||
fmt.Println(os.ExpandEnv(userCfgFile))
|
|
||||||
if _, err := os.Stat(os.ExpandEnv(userCfgFile)); err == nil {
|
if _, err := os.Stat(os.ExpandEnv(userCfgFile)); err == nil {
|
||||||
loadConfig(os.ExpandEnv(userCfgFile), cfg)
|
loadConfig(os.ExpandEnv(userCfgFile), cfg)
|
||||||
}
|
}
|
||||||
@ -135,7 +135,7 @@ func listWorkers(c *cli.Context) error {
|
|||||||
err.Error()),
|
err.Error()),
|
||||||
1)
|
1)
|
||||||
}
|
}
|
||||||
fmt.Print(string(b))
|
fmt.Println(string(b))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -185,7 +185,7 @@ func listJobs(c *cli.Context) error {
|
|||||||
fmt.Sprintf("Error printing out informations: %s", err.Error()),
|
fmt.Sprintf("Error printing out informations: %s", err.Error()),
|
||||||
1)
|
1)
|
||||||
}
|
}
|
||||||
fmt.Printf(string(b))
|
fmt.Println(string(b))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,9 +24,12 @@ func InitLogger(verbose, debug, withSystemd bool) {
|
|||||||
|
|
||||||
if debug {
|
if debug {
|
||||||
logging.SetLevel(logging.DEBUG, "tunasync")
|
logging.SetLevel(logging.DEBUG, "tunasync")
|
||||||
|
logging.SetLevel(logging.DEBUG, "tunasynctl-cmd")
|
||||||
} else if verbose {
|
} else if verbose {
|
||||||
logging.SetLevel(logging.INFO, "tunasync")
|
logging.SetLevel(logging.INFO, "tunasync")
|
||||||
|
logging.SetLevel(logging.INFO, "tunasynctl-cmd")
|
||||||
} else {
|
} else {
|
||||||
logging.SetLevel(logging.NOTICE, "tunasync")
|
logging.SetLevel(logging.NOTICE, "tunasync")
|
||||||
|
logging.SetLevel(logging.NOTICE, "tunasynctl-cmd")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -96,7 +96,7 @@ func (p *cmdProvider) Run() error {
|
|||||||
}
|
}
|
||||||
if p.failOnMatch != nil {
|
if p.failOnMatch != nil {
|
||||||
matches, err := internal.FindAllSubmatchInFile(p.LogFile(), p.failOnMatch)
|
matches, err := internal.FindAllSubmatchInFile(p.LogFile(), p.failOnMatch)
|
||||||
fmt.Printf("FindAllSubmatchInFile: %q\n", matches)
|
logger.Infof("FindAllSubmatchInFile: %q\n", matches)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user