mirror of
https://github.com/grafana/grafana.git
synced 2025-02-10 15:45:43 -06:00
feat(logging): added uname to context logger
This commit is contained in:
parent
a02cf5beb7
commit
65aad44464
@ -158,29 +158,6 @@ func ReadLoggingConfig(modes []string, logsPath string, cfg *ini.File) {
|
||||
loggersToClose = append(loggersToClose, fileHandler)
|
||||
handler = fileHandler
|
||||
|
||||
// case "conn":
|
||||
// LogConfigs[i] = util.DynMap{
|
||||
// "level": level,
|
||||
// "reconnectOnMsg": sec.Key("reconnect_on_msg").MustBool(),
|
||||
// "reconnect": sec.Key("reconnect").MustBool(),
|
||||
// "net": sec.Key("protocol").In("tcp", []string{"tcp", "unix", "udp"}),
|
||||
// "addr": sec.Key("addr").MustString(":7020"),
|
||||
// }
|
||||
// case "smtp":
|
||||
// LogConfigs[i] = util.DynMap{
|
||||
// "level": level,
|
||||
// "user": sec.Key("user").MustString("example@example.com"),
|
||||
// "passwd": sec.Key("passwd").MustString("******"),
|
||||
// "host": sec.Key("host").MustString("127.0.0.1:25"),
|
||||
// "receivers": sec.Key("receivers").MustString("[]"),
|
||||
// "subject": sec.Key("subject").MustString("Diagnostic message from serve"),
|
||||
// }
|
||||
// case "database":
|
||||
// LogConfigs[i] = util.DynMap{
|
||||
// "level": level,
|
||||
// "driver": sec.Key("driver").String(),
|
||||
// "conn": sec.Key("conn").String(),
|
||||
// }
|
||||
// case "syslog":
|
||||
// LogConfigs[i] = util.DynMap{
|
||||
// "level": level,
|
||||
|
@ -48,7 +48,7 @@ func Logger() macaron.Handler {
|
||||
|
||||
if ctx, ok := c.Data["ctx"]; ok {
|
||||
ctxTyped := ctx.(*Context)
|
||||
ctxTyped.Logger.Info("Request Completed", "method", req.Method, "path", req.URL.Path, "status", status, "remote_addr", c.RemoteAddr(), "uname", ctxTyped.Login, "time_ns", timeTakenMs, "size", rw.Size())
|
||||
ctxTyped.Logger.Info("Request Completed", "method", req.Method, "path", req.URL.Path, "status", status, "remote_addr", c.RemoteAddr(), "time_ns", timeTakenMs, "size", rw.Size())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ func GetContextHandler() macaron.Handler {
|
||||
initContextWithAnonymousUser(ctx) {
|
||||
}
|
||||
|
||||
ctx.Logger = log.New("context", "user", ctx.UserId, "orgId", ctx.OrgId)
|
||||
ctx.Logger = log.New("context", "userId", ctx.UserId, "orgId", ctx.OrgId, "uname", ctx.Login)
|
||||
ctx.Data["ctx"] = ctx
|
||||
|
||||
c.Map(ctx)
|
||||
|
Loading…
Reference in New Issue
Block a user