From 08ddeac03fd3832d44a3dfb48ee85ecd95d2b388 Mon Sep 17 00:00:00 2001 From: Ondrej Fabry Date: Tue, 21 Aug 2018 22:32:11 +0200 Subject: Make the warnings for validating services more obvious - there is currently simple validation for services, which checks type of services and its name for request/reply - there is one known warning in dhcp package for dhcp_client_config, since it is single case for normal requests subscribing to event Change-Id: I504a52b9a1823ced841b2ead712318ef5e5477b1 Signed-off-by: Ondrej Fabry --- cmd/binapi-generator/main.go | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'cmd/binapi-generator/main.go') diff --git a/cmd/binapi-generator/main.go b/cmd/binapi-generator/main.go index 8045212..b73a699 100644 --- a/cmd/binapi-generator/main.go +++ b/cmd/binapi-generator/main.go @@ -20,13 +20,13 @@ import ( "flag" "fmt" "io/ioutil" - "log" "os" "os/exec" "path/filepath" "strings" "github.com/bennyscetbun/jsongo" + "github.com/sirupsen/logrus" ) var ( @@ -38,15 +38,26 @@ var ( continueOnError = flag.Bool("continue-onerror", false, "Wheter to continue with next file on error.") ) +func init() { + flag.Parse() + if *debug { + logrus.SetLevel(logrus.DebugLevel) + } +} + func logf(f string, v ...interface{}) { if *debug { - log.Printf(f, v...) + logrus.Debugf(f, v...) } } -func main() { - flag.Parse() +var log = logrus.Logger{ + Level: logrus.InfoLevel, + Formatter: &logrus.TextFormatter{}, + Out: os.Stdout, +} +func main() { if *inputFile == "" && *inputDir == "" { fmt.Fprintln(os.Stderr, "ERROR: input-file or input-dir must be specified") os.Exit(1) @@ -143,7 +154,7 @@ func generateFromFile(inputFile, outputDir string) error { // count number of lines in generated output file cmd = exec.Command("wc", "-l", ctx.outputFile) if output, err := cmd.CombinedOutput(); err != nil { - log.Printf("wc command failed: %v\n%s", err, string(output)) + log.Warnf("wc command failed: %v\n%s", err, string(output)) } else { logf("generated lines: %s", output) } -- cgit 1.2.3-korg