summaryrefslogtreecommitdiffstats
path: root/cmd/binapi-generator/main.go
diff options
context:
space:
mode:
authorOndrej Fabry <ofabry@cisco.com>2018-08-21 22:32:11 +0200
committerOndrej Fabry <ofabry@cisco.com>2018-08-21 22:32:11 +0200
commit08ddeac03fd3832d44a3dfb48ee85ecd95d2b388 (patch)
tree6b94f6acc86686dfb078cd21c7d67865cac4ae8f /cmd/binapi-generator/main.go
parentc4ccfc75f0698e148cfa37a3a1dda1a46bb29109 (diff)
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 <ofabry@cisco.com>
Diffstat (limited to 'cmd/binapi-generator/main.go')
-rw-r--r--cmd/binapi-generator/main.go21
1 files changed, 16 insertions, 5 deletions
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)
}