Skip to content

Commit

Permalink
Set log-level. Add github link.
Browse files Browse the repository at this point in the history
  • Loading branch information
brocaar committed Mar 6, 2016
1 parent 861b568 commit dd1ff27
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions cmd/semtech-bridge/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import (
var version string // set by the compiler

func run(c *cli.Context) {
log.SetLevel(log.Level(uint8(c.Int("log-level"))))

pubsub, err := mqttpubsub.NewBackend(c.String("mqtt-server"), c.String("mqtt-username"), c.String("mqtt-password"))
if err != nil {
log.Fatalf("could not setup mqtt backend: %s", err)
Expand Down Expand Up @@ -71,6 +73,7 @@ func main() {
app := cli.NewApp()
app.Name = "semtech-bridge"
app.Usage = "Semtech UDP protocol speaking gateway <-> MQTT"
app.Copyright = "See http://github.com/brocaar/lora-semtech-bridge for copyright information"
app.Version = version
app.Action = run
app.Flags = []cli.Flag{
Expand All @@ -96,6 +99,12 @@ func main() {
Usage: "MQTT password",
EnvVar: "MQTT_PASSWORD",
},
cli.IntFlag{
Name: "log-level",
Value: 4,
Usage: "debug=5, info=4, warning=3, error=2, fatal=1, panic=0",
EnvVar: "LOG_LEVEL",
},
}
app.Run(os.Args)
}

0 comments on commit dd1ff27

Please sign in to comment.