Fix build after go module update

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

@ -7,29 +7,30 @@ import (
"time"
)
// Logger interface
type Logger interface {
Println(v ...interface{})
Printf(format string, v ...interface{})
// Logger type
type Logger struct {
logger *log.Logger
}
// LoggerHandler interface
type LoggerHandler interface {
Logger
ServeHTTP(http.ResponseWriter, *http.Request, http.HandlerFunc)
// NewLogger returns a logger interface
func NewLogger() *Logger {
return &Logger{
logger: log.New(os.Stdout, appLabel, log.Ldate|log.Lmicroseconds),
}
}
// NewLogger returns a logger interface
func NewLogger() LoggerHandler {
return &logger{log.New(os.Stdout, appLabel, log.Ldate|log.Lmicroseconds)}
// Println is proxy for println
func (l *Logger) Println(v ...interface{}) {
l.logger.Println(v...)
}
type logger struct {
Logger
// Printf calls Printf on 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()
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
type Server struct {
headerNames []string
logger LoggerHandler
logger *Logger
tmpl *template.Template
}

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

Loading…
Cancel
Save