summaryrefslogtreecommitdiff
path: root/vendor/github.com/gin-gonic/gin/logger.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/gin-gonic/gin/logger.go')
-rw-r--r--vendor/github.com/gin-gonic/gin/logger.go17
1 files changed, 8 insertions, 9 deletions
diff --git a/vendor/github.com/gin-gonic/gin/logger.go b/vendor/github.com/gin-gonic/gin/logger.go
index d361b74d3..cd1e7fa6e 100644
--- a/vendor/github.com/gin-gonic/gin/logger.go
+++ b/vendor/github.com/gin-gonic/gin/logger.go
@@ -1,4 +1,4 @@
-// Copyright 2014 Manu Martinez-Almeida. All rights reserved.
+// Copyright 2014 Manu Martinez-Almeida. All rights reserved.
// Use of this source code is governed by a MIT style
// license that can be found in the LICENSE file.
@@ -44,7 +44,7 @@ type LoggerConfig struct {
// Optional. Default value is gin.DefaultWriter.
Output io.Writer
- // SkipPaths is a url path array which logs are not written.
+ // SkipPaths is an url path array which logs are not written.
// Optional.
SkipPaths []string
}
@@ -70,12 +70,12 @@ type LogFormatterParams struct {
Path string
// ErrorMessage is set if error has occurred in processing the request.
ErrorMessage string
- // isTerm shows whether does gin's output descriptor refers to a terminal.
+ // isTerm shows whether gin's output descriptor refers to a terminal.
isTerm bool
// BodySize is the size of the Response Body
BodySize int
// Keys are the keys set on the request's context.
- Keys map[string]interface{}
+ Keys map[string]any
}
// StatusCodeColor is the ANSI color for appropriately logging http status code to a terminal.
@@ -138,8 +138,7 @@ var defaultLogFormatter = func(param LogFormatterParams) string {
}
if param.Latency > time.Minute {
- // Truncate in a golang < 1.8 safe way
- param.Latency = param.Latency - param.Latency%time.Second
+ param.Latency = param.Latency.Truncate(time.Second)
}
return fmt.Sprintf("[GIN] %v |%s %3d %s| %13v | %15s |%s %-7s %s %#v\n%s",
param.TimeStamp.Format("2006/01/02 - 15:04:05"),
@@ -162,12 +161,12 @@ func ForceConsoleColor() {
consoleColorMode = forceColor
}
-// ErrorLogger returns a handlerfunc for any error type.
+// ErrorLogger returns a HandlerFunc for any error type.
func ErrorLogger() HandlerFunc {
return ErrorLoggerT(ErrorTypeAny)
}
-// ErrorLoggerT returns a handlerfunc for a given error type.
+// ErrorLoggerT returns a HandlerFunc for a given error type.
func ErrorLoggerT(typ ErrorType) HandlerFunc {
return func(c *Context) {
c.Next()
@@ -179,7 +178,7 @@ func ErrorLoggerT(typ ErrorType) HandlerFunc {
}
// Logger instances a Logger middleware that will write the logs to gin.DefaultWriter.
-// By default gin.DefaultWriter = os.Stdout.
+// By default, gin.DefaultWriter = os.Stdout.
func Logger() HandlerFunc {
return LoggerWithConfig(LoggerConfig{})
}