Skip to content

Commit

Permalink
Merge pull request #24 from klpx/log-level-parameter
Browse files Browse the repository at this point in the history
Proper log level setup
  • Loading branch information
Gediminas Šedbaras authored Feb 8, 2019
2 parents 9fef68d + 86629d9 commit bc996ba
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/.idea/
*.deb
*.swp
/bin
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ Use the `-h` flag to get help information.
```
$ pushprom -h
Usage of bin/pushprom:
-debug
Log debugging messages.
-http-listen-address string
The address to listen on for http stat and telemetry requests. (default ":9091")
-log-level string
Log level: debug, info (default), warn, error, fatal. (default "info")
-udp-listen-address string
The address to listen on for udp stats requests. (default ":9090")
```
Expand Down
6 changes: 5 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
)

var (
debug = flag.Bool("debug", false, "Log debugging messages.")
logLevel = flag.String("log-level", "info", "Log level: debug, info (default), warn, error, fatal.")
udpListenAddress = flag.String("udp-listen-address", "0.0.0.0:9090", "The address to listen on for udp stats requests.")
httpListenAddress = flag.String("http-listen-address", "0.0.0.0:9091", "The address to listen on for http stat and telemetry requests.")
)
Expand All @@ -26,6 +26,10 @@ func main() {

var err error

if err = logger.SetLevel(*logLevel); err != nil {
log.Fatalf(err.Error())
}

*udpListenAddress, err = ListenAddress(*udpListenAddress)
if err != nil {
log.Fatalf(err.Error())
Expand Down
6 changes: 3 additions & 3 deletions udp.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ func listenUDP(ctx context.Context, log plog.Logger) {
continue
}
udpPacketCount.Inc()
if *debug {
log.Debugf("new udp package: %s", string(buf[0:n]))
}

log.Debugf("new udp package: %s", string(buf[0:n]))

delta, err := NewDelta(bytes.NewBuffer(buf[0:n]))
if err != nil {
log.Error("Error creating delta: ", err)
Expand Down

0 comments on commit bc996ba

Please sign in to comment.