Fix build after go module update

master
Buddy Sandidge 5 years ago
parent 578ab7b880
commit 54f3f5aae7

@ -7,29 +7,30 @@ import (
"time" "time"
) )
// Logger interface // Logger type
type Logger interface { type Logger struct {
Println(v ...interface{}) logger *log.Logger
Printf(format string, v ...interface{})
} }
// LoggerHandler interface // NewLogger returns a logger interface
type LoggerHandler interface { func NewLogger() *Logger {
Logger return &Logger{
ServeHTTP(http.ResponseWriter, *http.Request, http.HandlerFunc) logger: log.New(os.Stdout, appLabel, log.Ldate|log.Lmicroseconds),
}
} }
// NewLogger returns a logger interface // Println is proxy for println
func NewLogger() LoggerHandler { func (l *Logger) Println(v ...interface{}) {
return &logger{log.New(os.Stdout, appLabel, log.Ldate|log.Lmicroseconds)} l.logger.Println(v...)
} }
type logger struct { // Printf calls Printf on logger
Logger func (l *Logger) Printf(f string, v ...interface{}) {
l.logger.Printf(f, v...)
} }
func (l *logger) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc) { func (l *Logger) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc) {
start := time.Now() start := time.Now()
next(rw, r) next(rw, r)
l.Printf("Completed %s to %s in %v", r.Method, r.URL.Path, time.Since(start)) l.logger.Printf("Completed %s to %s in %v", r.Method, r.URL.Path, time.Since(start))
} }

@ -14,7 +14,7 @@ import (
// Server that handles http responses // Server that handles http responses
type Server struct { type Server struct {
headerNames []string headerNames []string
logger LoggerHandler logger *Logger
tmpl *template.Template tmpl *template.Template
} }

@ -5,7 +5,7 @@ import (
"net/http" "net/http"
"os" "os"
"github.com/GeertJohan/go.rice" rice "github.com/GeertJohan/go.rice"
"github.com/gorilla/pat" "github.com/gorilla/pat"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/urfave/cli" "github.com/urfave/cli"
@ -85,7 +85,7 @@ func getHandler(headers []string) (http.Handler, *Server, error) {
} }
recover := negroni.NewRecovery() recover := negroni.NewRecovery()
recover.Logger = service.logger recover.Logger = service.logger.logger
router := pat.New() router := pat.New()

Loading…
Cancel
Save