feat(logging): added uname to context logger

This commit is contained in:
Torkel Ödegaard
2016-06-07 12:20:46 +02:00
parent a02cf5beb7
commit 65aad44464
3 changed files with 2 additions and 25 deletions

View File

@@ -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())
}
}
}

View File

@@ -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)