LoggerWithConfig() — gin Function Reference
Architecture documentation for the LoggerWithConfig() function in logger.go from the gin codebase.
Entity Profile
Dependency Diagram
graph TD 45fb2247_0486_a921_37f5_cab379de4eab["LoggerWithConfig()"] ed464f46_6294_af3d_9831_5646cd0d38c7["logger.go"] 45fb2247_0486_a921_37f5_cab379de4eab -->|defined in| ed464f46_6294_af3d_9831_5646cd0d38c7 c1bc7f84_8242_d059_9ba7_9ae58f11469b["Logger()"] c1bc7f84_8242_d059_9ba7_9ae58f11469b -->|calls| 45fb2247_0486_a921_37f5_cab379de4eab e1343555_d3b2_4165_765a_c840ea36f659["LoggerWithFormatter()"] e1343555_d3b2_4165_765a_c840ea36f659 -->|calls| 45fb2247_0486_a921_37f5_cab379de4eab fb465c9b_10e7_61ca_6e7c_427ee3370226["LoggerWithWriter()"] fb465c9b_10e7_61ca_6e7c_427ee3370226 -->|calls| 45fb2247_0486_a921_37f5_cab379de4eab style 45fb2247_0486_a921_37f5_cab379de4eab 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
Defined In
Source
Frequently Asked Questions
What does LoggerWithConfig() do?
LoggerWithConfig() is a function in the gin codebase, defined in logger.go.
Where is LoggerWithConfig() defined?
LoggerWithConfig() is defined in logger.go at line 240.
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