From 911c0d9f85a965f6b85d4939ea5824cc8915a235 Mon Sep 17 00:00:00 2001 From: Stephen J Day Date: Thu, 23 Jul 2015 20:51:11 -0700 Subject: [PATCH] Do not replace logger when adding hooks Because the logger was incorrectly replaced while adding hooks, log output did not include the version and instance ids. The main issue was the the logrus.Entry was replaced with the logger, which included no context. Replacing the logger on the context is not necessary when configuring hooks since we are configuring the contexts logger directly. Signed-off-by: Stephen J Day --- docs/handlers/app.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/docs/handlers/app.go b/docs/handlers/app.go index f61b2c1e0..85b4f70b5 100644 --- a/docs/handlers/app.go +++ b/docs/handlers/app.go @@ -298,7 +298,14 @@ func (app *App) configureRedis(configuration *configuration.Configuration) { // configureLogHook prepares logging hook parameters. func (app *App) configureLogHook(configuration *configuration.Configuration) { - logger := ctxu.GetLogger(app).(*log.Entry).Logger + entry, ok := ctxu.GetLogger(app).(*log.Entry) + if !ok { + // somehow, we are not using logrus + return + } + + logger := entry.Logger + for _, configHook := range configuration.Log.Hooks { if !configHook.Disabled { switch configHook.Type { @@ -318,7 +325,6 @@ func (app *App) configureLogHook(configuration *configuration.Configuration) { } } } - app.Context = ctxu.WithLogger(app.Context, logger) } func (app *App) ServeHTTP(w http.ResponseWriter, r *http.Request) {