X-Git-Url: https://ruderich.org/simon/gitweb/?a=blobdiff_plain;f=cmd%2Fsafcm%2Fsync.go;h=10edc68755e98c81e2c890745d3e3f706d3a3691;hb=b0f49e5d47786984e24731b200d3d3d7d6add263;hp=c1ecc965eec221828788f2bf68acd1481f08d78e;hpb=c899e17495d4eb932e0b4f428ec91882d845f1bc;p=safcm%2Fsafcm.git diff --git a/cmd/safcm/sync.go b/cmd/safcm/sync.go index c1ecc96..10edc68 100644 --- a/cmd/safcm/sync.go +++ b/cmd/safcm/sync.go @@ -66,22 +66,9 @@ func MainSync(args []string) error { flag.CommandLine.Parse(args[2:]) - var level safcm.LogLevel - switch *optionLog { - case "error": - level = safcm.LogError - case "info": - level = safcm.LogInfo - case "verbose": - level = safcm.LogVerbose - case "debug": - level = safcm.LogDebug - case "debug2": - level = safcm.LogDebug2 - case "debug3": - level = safcm.LogDebug3 - default: - return fmt.Errorf("invalid -log value %q", *optionLog) + level, err := safcm.ParseLogLevel(*optionLog) + if err != nil { + return fmt.Errorf("-log: %v", err) } names := flag.Args() @@ -127,12 +114,12 @@ func MainSync(args []string) error { var hosts []frontend.Host for _, x := range toSync { s := &Sync{ - host: x, - config: cfg, - allHosts: allHosts, - allGroups: allGroups, - isTTY: isTTY, - } + host: x, + config: cfg, + allHosts: allHosts, + allGroups: allGroups, + isTTY: isTTY, + } s.logFunc = func(level safcm.LogLevel, escaped bool, msg string) { loop.Log(s, level, escaped, msg)