forked from mirror/gin
Use `Duration.Truncate` for truncating precision (#2711)
`Duration.Truncate` was added in Go 1.9 and Gin required Go version 1.13+ now. So we can use `Duration.Truncate`. Co-authored-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
parent
5452a1d3ef
commit
4fe5f3e4b4
|
@ -138,8 +138,7 @@ var defaultLogFormatter = func(param LogFormatterParams) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
if param.Latency > time.Minute {
|
if param.Latency > time.Minute {
|
||||||
// Truncate in a golang < 1.8 safe way
|
param.Latency = param.Latency.Truncate(time.Second)
|
||||||
param.Latency = param.Latency - param.Latency%time.Second
|
|
||||||
}
|
}
|
||||||
return fmt.Sprintf("[GIN] %v |%s %3d %s| %13v | %15s |%s %-7s %s %#v\n%s",
|
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"),
|
param.TimeStamp.Format("2006/01/02 - 15:04:05"),
|
||||||
|
|
Loading…
Reference in New Issue