Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func LoggerWithWriter(out io.Writer, notlogged ...string) HandlerFunc {
path = path + "?" + raw
}

fmt.Fprintf(out, "[GIN] %v |%s %3d %s| %13v | %15s |%s %-7s %s %s\n%s",
fmt.Fprintf(out, "[GIN] %v |%s %3d %s| %13v | %39s |%s %-7s %s %s\n%s",
end.Format("2006/01/02 - 15:04:05"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check the client ip length first. Please try the following example.

width := 0
if len(clientIP) > 15 {
  width = 39
} else {
  width = 15
}

fmt.Printf("%*s\n", width, "Hello World!")

see https://play.golang.org/p/pLKiETJ-NX

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

width := 15
if len(clientIP) > 15 {
  width = 39
}

statusColor, statusCode, resetColor,
latency,
Expand Down