mirror of
https://github.com/zrepl/zrepl.git
synced 2025-02-02 03:29:13 +01:00
client/configcheck: check logging config
This commit is contained in:
parent
3e359aaeda
commit
44d2057df8
@ -10,6 +10,8 @@ import (
|
||||
"github.com/zrepl/zrepl/cli"
|
||||
"github.com/zrepl/zrepl/config"
|
||||
"github.com/zrepl/zrepl/daemon/job"
|
||||
"github.com/zrepl/zrepl/daemon/logging"
|
||||
"github.com/zrepl/zrepl/logger"
|
||||
"os"
|
||||
)
|
||||
|
||||
@ -23,7 +25,7 @@ var ConfigcheckCmd = &cli.Subcommand{
|
||||
Short: "check if config can be parsed without errors",
|
||||
SetupFlags: func(f *pflag.FlagSet) {
|
||||
f.StringVar(&configcheckArgs.format, "format", "", "dump parsed config object [pretty|yaml|json]")
|
||||
f.StringVar(&configcheckArgs.what, "what", "all", "what to print [all|config|jobs]")
|
||||
f.StringVar(&configcheckArgs.what, "what", "all", "what to print [all|config|jobs|logging]")
|
||||
},
|
||||
Run: func(subcommand *cli.Subcommand, args []string) error {
|
||||
formatMap := map[string]func(interface{}) {
|
||||
@ -56,14 +58,30 @@ var ConfigcheckCmd = &cli.Subcommand{
|
||||
}
|
||||
}
|
||||
|
||||
// further: try to build logging outlets
|
||||
outlets, err := logging.OutletsFromConfig(*subcommand.Config().Global.Logging)
|
||||
if err != nil {
|
||||
err := errors.Wrap(err, "cannot build logging from config")
|
||||
if configcheckArgs.what == "logging" {
|
||||
return err
|
||||
} else {
|
||||
fmt.Fprintf(os.Stderr, "%s\n", err)
|
||||
outlets = nil
|
||||
hadErr = true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
whatMap := map[string]func() {
|
||||
"all": func() {
|
||||
o := struct {
|
||||
config *config.Config
|
||||
jobs []job.Job
|
||||
logging *logger.Outlets
|
||||
}{
|
||||
subcommand.Config(),
|
||||
confJobs,
|
||||
outlets,
|
||||
}
|
||||
formatter(o)
|
||||
},
|
||||
@ -73,6 +91,9 @@ var ConfigcheckCmd = &cli.Subcommand{
|
||||
"jobs": func() {
|
||||
formatter(confJobs)
|
||||
},
|
||||
"logging": func() {
|
||||
formatter(outlets)
|
||||
},
|
||||
}
|
||||
|
||||
wf, ok := whatMap[configcheckArgs.what]
|
||||
|
Loading…
Reference in New Issue
Block a user