Skip to content
Myr

Revert "Merge pull request #744 from aviddiviner/logger-fix"

Before adoption: this commit came in with the history the project adopted, so no landing records it.

This reverts commit c3bfd69303d0fdaf2d43a7ff07cc8ee45ec7bb3f, reversing changes made to 9177f01c2843b91820780197f521ba48554b9df3.

authored by Javier Provecho Fernandez · committed by Javier Provecho Fernandez · parent 7dc96be · Browse files · 1 file+2 added−13 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+2 added−13 removed

  • other:+2 added−13 removed

1 file+2 added−13 removed

modified:logger.go+2 added-13 removed
5 unmodified lines
67import (8 "fmt"9 "io"10 "os"10 "time"1213 "golang.org/x/crypto/ssh/terminal"11)1213var (14 green = string([]byte{27, 91, 57, 55, 59, 52, 50, 109})
28 unmodified lines
4344// LoggerWithWriter instance a Logger middleware with the specified writter buffer.45// Example: os.Stdout, a file opened in write mode, a socket...46func LoggerWithWriter(out io.Writer, notlogged ...string) HandlerFunc {50 isTerm := true51 if outFile, ok := out.(*os.File); ok {52 isTerm = terminal.IsTerminal(int(outFile.Fd()))53 }5447 var skip map[string]struct{}4849 if length := len(notlogged); length > 0 {50 skip = make(map[string]struct{}, length)
19 unmodified lines
7071 clientIP := c.ClientIP()72 method := c.Request.Method73 statusCode := c.Writer.Status()82 var statusColor, methodColor string83 if isTerm {84 statusColor = colorForStatus(statusCode)85 methodColor = colorForMethod(method)74 statusColor := colorForStatus(statusCode)75 methodColor := colorForMethod(method)86 }76 comment := c.Errors.ByType(ErrorTypePrivate).String()7778 fmt.Fprintf(out, "[GIN] %v |%s %3d %s| %13v | %s |%s %s %-7s %s\n%s",79 end.Format("2006/01/02 - 15:04:05"),
44 unmodified lines