Skip to content

Commit

Permalink
Allow to configure fritzctl log level (default to "warn" now)
Browse files Browse the repository at this point in the history
The default log level used to be "info" which seems unnecessary high and
leads to "Login sucessfull" messages all over the place. This change
sets the default level to "warn", adding a flag to make it configurable.
  • Loading branch information
jayme-github committed Apr 24, 2022
1 parent 6fad353 commit 2113e0c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Export information about your smarthome devices (switches, powermeters, thermost
```
Usage of ./fritzbox_smarthome_exporter:
-cert="": Path to the FRITZ!Box certificate.
-loglevel="warn": Logging verbosity (debug, info, warn or error)
-noverify=false: Omit TLS verification of the FRITZ!Box certificate.
-password="": FRITZ!Box password.
-url="https://fritz.box": FRITZ!Box URL.
Expand Down
8 changes: 8 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"time"

"github.com/bpicode/fritzctl/fritz"
fritzctllogger "github.com/bpicode/fritzctl/logger"

"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
Expand Down Expand Up @@ -50,11 +51,18 @@ var (
urlString = flag.String("url", "https://fritz.box", "FRITZ!Box URL.")
noVerify = flag.Bool("noverify", false, "Omit TLS verification of the FRITZ!Box certificate.")
certificatePath = flag.String("cert", "", "Path to the FRITZ!Box certificate.")
loglevel = flag.String("loglevel", "warn", "Logging verbosity (debug, info, warn, error or none)")
)

func validateFlags() {
var err error
flag.Parse()

l := &fritzctllogger.Level{}
if err := l.Set(*loglevel); err != nil {
log.Fatalln(err)
}

fbURL, err = url.Parse(*urlString)
if err != nil {
log.Fatalln(err)
Expand Down

0 comments on commit 2113e0c

Please sign in to comment.