Commit 65aad444 by Torkel Ödegaard

feat(logging): added uname to context logger

parent a02cf5be
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment