add log output and use the prometheus log library

This commit is contained in:
WilliButz 2018-05-06 15:13:33 +02:00
parent 025856a69c
commit 55f7e71b1e
No known key found for this signature in database
GPG key ID: 92582A10F1179CB2

View file

@ -19,7 +19,6 @@ import (
"bufio" "bufio"
"flag" "flag"
"fmt" "fmt"
"log"
"net/http" "net/http"
"os" "os"
"strconv" "strconv"
@ -29,6 +28,7 @@ import (
"github.com/miekg/dns" "github.com/miekg/dns"
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp" "github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/prometheus/common/log"
) )
var ( var (
@ -163,6 +163,7 @@ func (s *server) metrics(w http.ResponseWriter, r *http.Request) {
eg.Go(func() error { eg.Go(func() error {
f, err := os.Open(s.leasesPath) f, err := os.Open(s.leasesPath)
if err != nil { if err != nil {
log.Warnln("could not open leases file:", err)
return err return err
} }
defer f.Close() defer f.Close()
@ -205,5 +206,7 @@ func main() {
<p><a href="` + *metricsPath + `">Metrics</a></p> <p><a href="` + *metricsPath + `">Metrics</a></p>
</body></html>`)) </body></html>`))
}) })
log.Infoln("Listening on", *listen)
log.Infoln("Serving metrics under", *metricsPath)
log.Fatal(http.ListenAndServe(*listen, nil)) log.Fatal(http.ListenAndServe(*listen, nil))
} }