NewAccessLogger builds and returns a logger configured for HTTP access logging using the provided log configuration. If log_media is "file", the access log is written to the provided filename inside LogDir. For "stdout" or "syslog", the access logger uses the same output destination as the standard
(cfg LogConfig, filename string)
| 250 | // inside LogDir. For "stdout" or "syslog", the access logger uses the same |
| 251 | // output destination as the standard logger. |
| 252 | func (c *LocalApiServerCfg) NewAccessLogger(cfg LogConfig, filename string) *log.Entry { |
| 253 | media := cfg.GetMedia() |
| 254 | logger := log.WithField("output", media) |
| 255 | |
| 256 | defer func() { |
| 257 | logger.Debug("starting access logger") |
| 258 | }() |
| 259 | |
| 260 | accessLogger := logging.SubLogger(log.StandardLogger(), "lapi", c.LogLevel) |
| 261 | |
| 262 | if media != "file" { |
| 263 | return accessLogger |
| 264 | } |
| 265 | |
| 266 | logPath := filepath.Join(cfg.GetDir(), filename) |
| 267 | logger = logger.WithField("file", logPath) |
| 268 | |
| 269 | accessLogger.Logger.SetOutput(cfg.NewRotatingLogger(filename)) |
| 270 | |
| 271 | return accessLogger |
| 272 | } |
| 273 | |
| 274 | func (c *LocalApiServerCfg) NewPAPILogger() *log.Entry { |
| 275 | level := cmp.Or(c.PapiLogLevel, c.LogLevel) |
no test coverage detected