Skip to content

Commit

Permalink
fix: ensure a default logger is present if none is given
Browse files Browse the repository at this point in the history
  • Loading branch information
ladydascalie committed Jan 10, 2023
1 parent e0a49ca commit 1f87a21
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion flexmetrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package flexmetrics

import (
"context"
"log"
"net"
"net/http"
"net/http/pprof"
Expand Down Expand Up @@ -31,6 +32,9 @@ const (
DefaultWriteTimeout = 15 * time.Second
)

// default package logger to be used if no logger is provided.
var logger = log.New(os.Stderr, "flexmetrics: ", 0)

// Option is a type of func that allows you change defaults of the *Server
// returned by New.
type Option func(s *Server)
Expand Down Expand Up @@ -86,7 +90,8 @@ func New(options ...Option) *Server {
}

server := &Server{
Path: path,
logger: logger,
Path: path,
Server: &http.Server{
Addr: addr,
ReadTimeout: DefaultReadTimeout,
Expand Down

0 comments on commit 1f87a21

Please sign in to comment.