Merge pull request #5 from bombsimon/field-logger

Use interface to create logger
This commit is contained in:
Stéphane Depierrepont 2019-07-01 15:14:13 +02:00 committed by GitHub
commit 6c374ad36b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -19,7 +19,7 @@ import (
var timeFormat = "02/Jan/2006:15:04:05 -0700"
// Logger is the logrus logger handler
func Logger(log *logrus.Logger) gin.HandlerFunc {
func Logger(logger logrus.FieldLogger) gin.HandlerFunc {
hostname, err := os.Hostname()
if err != nil {
hostname = "unknow"
@ -40,7 +40,7 @@ func Logger(log *logrus.Logger) gin.HandlerFunc {
dataLength = 0
}
entry := logrus.NewEntry(log).WithFields(logrus.Fields{
entry := logger.WithFields(logrus.Fields{
"hostname": hostname,
"statusCode": statusCode,
"latency": latency, // time to process