Skip to content

Commit

Permalink
feat: add ability for verbose logging
Browse files Browse the repository at this point in the history
Debug messages can now be shown when specifying the "-verbose" flag on
the command line. This sets the logrus log level to "Debug".
  • Loading branch information
particledecay committed Jan 26, 2022
1 parent 6e6d0d2 commit b9d7bdc
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"encoding/json"
"flag"
"net/http"
"strconv"
"time"
Expand Down Expand Up @@ -111,7 +112,14 @@ func setHeartRateSeconds(w http.ResponseWriter, r *http.Request) {
}

func main() {
verbose := flag.Bool("verbose", false, "show debug messages")
flag.Parse()

log.SetFormatter(&log.JSONFormatter{})
// debug mode
if *verbose {
log.SetLevel(log.DebugLevel)
}

mainMux := mux.NewRouter()
mainMux.HandleFunc("/heart/{rate}", setHeartRateSeconds)
Expand Down

0 comments on commit b9d7bdc

Please sign in to comment.