LoggerWithConfig() — gin Function Reference
Architecture documentation for the LoggerWithConfig() function in logger.go from the gin codebase.
Entity Profile
Dependency Diagram
graph TD 23dcd09a_55f8_7c8f_a2ac_75c2ee7c77e9["LoggerWithConfig()"] 58f202c2_4dc9_abaa_7f0e_1204c43605c4["Logger()"] 58f202c2_4dc9_abaa_7f0e_1204c43605c4 -->|calls| 23dcd09a_55f8_7c8f_a2ac_75c2ee7c77e9 e005d662_6c0e_16fb_d330_18acbb78d114["LoggerWithFormatter()"] e005d662_6c0e_16fb_d330_18acbb78d114 -->|calls| 23dcd09a_55f8_7c8f_a2ac_75c2ee7c77e9 94b6132d_c753_c130_bd33_dc5a81ae148c["LoggerWithWriter()"] 94b6132d_c753_c130_bd33_dc5a81ae148c -->|calls| 23dcd09a_55f8_7c8f_a2ac_75c2ee7c77e9 style 23dcd09a_55f8_7c8f_a2ac_75c2ee7c77e9 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
logger.go lines 240–309
func LoggerWithConfig(conf LoggerConfig) HandlerFunc {
formatter := conf.Formatter
if formatter == nil {
formatter = defaultLogFormatter
}
out := conf.Output
if out == nil {
out = DefaultWriter
}
notlogged := conf.SkipPaths
isTerm := true
if w, ok := out.(*os.File); !ok || os.Getenv("TERM") == "dumb" ||
(!isatty.IsTerminal(w.Fd()) && !isatty.IsCygwinTerminal(w.Fd())) {
isTerm = false
}
var skip map[string]struct{}
if length := len(notlogged); length > 0 {
skip = make(map[string]struct{}, length)
for _, path := range notlogged {
skip[path] = struct{}{}
}
}
return func(c *Context) {
// Start timer
start := time.Now()
path := c.Request.URL.Path
raw := c.Request.URL.RawQuery
// Process request
c.Next()
// Log only when it is not being skipped
if _, ok := skip[path]; ok || (conf.Skip != nil && conf.Skip(c)) {
return
}
param := LogFormatterParams{
Request: c.Request,
isTerm: isTerm,
Keys: c.Keys,
}
// Stop timer
param.TimeStamp = time.Now()
param.Latency = param.TimeStamp.Sub(start)
param.ClientIP = c.ClientIP()
param.Method = c.Request.Method
param.StatusCode = c.Writer.Status()
param.ErrorMessage = c.Errors.ByType(ErrorTypePrivate).String()
param.BodySize = c.Writer.Size()
if raw != "" {
path = path + "?" + raw
}
param.Path = path
fmt.Fprint(out, formatter(param))
}
}
Domain
Subdomains
Source
Frequently Asked Questions
What does LoggerWithConfig() do?
LoggerWithConfig() is a function in the gin codebase.
What calls LoggerWithConfig()?
LoggerWithConfig() is called by 3 function(s): Logger, LoggerWithFormatter, LoggerWithWriter.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free