mirror of
https://github.com/zrepl/zrepl.git
synced 2025-05-01 14:54:28 +02: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/cli"
|
||||||
"github.com/zrepl/zrepl/config"
|
"github.com/zrepl/zrepl/config"
|
||||||
"github.com/zrepl/zrepl/daemon/job"
|
"github.com/zrepl/zrepl/daemon/job"
|
||||||
|
"github.com/zrepl/zrepl/daemon/logging"
|
||||||
|
"github.com/zrepl/zrepl/logger"
|
||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -23,7 +25,7 @@ var ConfigcheckCmd = &cli.Subcommand{
|
|||||||
Short: "check if config can be parsed without errors",
|
Short: "check if config can be parsed without errors",
|
||||||
SetupFlags: func(f *pflag.FlagSet) {
|
SetupFlags: func(f *pflag.FlagSet) {
|
||||||
f.StringVar(&configcheckArgs.format, "format", "", "dump parsed config object [pretty|yaml|json]")
|
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 {
|
Run: func(subcommand *cli.Subcommand, args []string) error {
|
||||||
formatMap := map[string]func(interface{}) {
|
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() {
|
whatMap := map[string]func() {
|
||||||
"all": func() {
|
"all": func() {
|
||||||
o := struct {
|
o := struct {
|
||||||
config *config.Config
|
config *config.Config
|
||||||
jobs []job.Job
|
jobs []job.Job
|
||||||
|
logging *logger.Outlets
|
||||||
}{
|
}{
|
||||||
subcommand.Config(),
|
subcommand.Config(),
|
||||||
confJobs,
|
confJobs,
|
||||||
|
outlets,
|
||||||
}
|
}
|
||||||
formatter(o)
|
formatter(o)
|
||||||
},
|
},
|
||||||
@ -73,6 +91,9 @@ var ConfigcheckCmd = &cli.Subcommand{
|
|||||||
"jobs": func() {
|
"jobs": func() {
|
||||||
formatter(confJobs)
|
formatter(confJobs)
|
||||||
},
|
},
|
||||||
|
"logging": func() {
|
||||||
|
formatter(outlets)
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
wf, ok := whatMap[configcheckArgs.what]
|
wf, ok := whatMap[configcheckArgs.what]
|
||||||
|
Loading…
Reference in New Issue
Block a user