Skip to content

Commit

Permalink
Merge pull request #4 from jacobbednarz/add-better-debug-support
Browse files Browse the repository at this point in the history
Add `-debug` flag
  • Loading branch information
jacobbednarz authored Jul 13, 2017
2 parents d2caf65 + a46b300 commit 36dacd7
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
7 changes: 7 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
builds:
- binary: csp-collector
goos:
- linux
- darwin
goarch:
- amd64
24 changes: 23 additions & 1 deletion csp_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ package main

import (
"encoding/json"
"flag"
"fmt"
"io"
"log"
"net/http"
"os"
"strings"
"time"
)
Expand All @@ -20,8 +23,27 @@ type CSPReport struct {
} `json:"csp-report"`
}

var (
Debug *log.Logger

// Flag for toggling verbose output.
debugFlag bool
)

func setupDebugLogger(debugHandle io.Writer) {
Debug = log.New(debugHandle, "[DEBUG] ", log.Lmicroseconds)
}

func main() {
log.Println("Starting up...")
setupDebugLogger(os.Stdout)

flag.BoolVar(&debugFlag, "debug", false, "Output additional logging for debugging")
flag.Parse()

if debugFlag {
Debug.Println("Starting up...")
}

http.HandleFunc("/", handleViolationReport)
log.Fatal(http.ListenAndServe(":8080", nil))
}
Expand Down

0 comments on commit 36dacd7

Please sign in to comment.