diff options
-rw-r--r-- | Bugzilla/Quantum/Plugin/Glue.pm | 11 | ||||
-rw-r--r-- | Log/Log4perl/Layout/Mozilla.pm | 3 | ||||
-rw-r--r-- | conf/log4perl-test.conf | 4 |
3 files changed, 11 insertions, 7 deletions
diff --git a/Bugzilla/Quantum/Plugin/Glue.pm b/Bugzilla/Quantum/Plugin/Glue.pm index 112514b63..301003740 100644 --- a/Bugzilla/Quantum/Plugin/Glue.pm +++ b/Bugzilla/Quantum/Plugin/Glue.pm @@ -53,16 +53,17 @@ sub register { } ); - if ($D{HTTPD_IN_SUBDIR}) { - $app->hook( - before_dispatch => sub { + $app->hook( + before_dispatch => sub { + if ($D{HTTPD_IN_SUBDIR}) { my ($c) = @_; my $path = $c->req->url->path; $path =~ s{^/bmo}{}s; $c->req->url->path($path); } - ); - } + Log::Log4perl::MDC->put(request_id => $c->req->request_id); + } + ); Bugzilla::Extension->load_all(); if ($app->mode ne 'development') { diff --git a/Log/Log4perl/Layout/Mozilla.pm b/Log/Log4perl/Layout/Mozilla.pm index b625c54f4..4aedd9843 100644 --- a/Log/Log4perl/Layout/Mozilla.pm +++ b/Log/Log4perl/Layout/Mozilla.pm @@ -53,6 +53,9 @@ sub render { my $mdc = Log::Log4perl::MDC->get_context; my $fields = $mdc->{fields} // {}; + if ($mdc->{request_id}) { + $fields->{request_id} = $mdc->{request_id} + } my %out = ( EnvVersion => LOGGING_FORMAT_VERSION, Hostname => $HOSTNAME, diff --git a/conf/log4perl-test.conf b/conf/log4perl-test.conf index 77fc00af8..e8acd58cf 100644 --- a/conf/log4perl-test.conf +++ b/conf/log4perl-test.conf @@ -4,14 +4,14 @@ log4perl.appender.Cereal.PeerAddr=127.0.0.1 log4perl.appender.Cereal.PeerPort=5880 log4perl.appender.Cereal.defer_connection=1 log4perl.appender.Cereal.layout = Log::Log4perl::Layout::PatternLayout -log4perl.appender.Cereal.layout.ConversionPattern = %d %6p | %c | %m{chomp}%n +log4perl.appender.Cereal.layout.ConversionPattern = [%X{request_id}] %d %6p | %c | %m{chomp}%n log4perl.filter.LOG_TO_STDERR = sub { not $ENV{LOG4PERL_STDERR_DISABLE} } log4perl.appender.Screen = Log::Log4perl::Appender::Screen log4perl.appender.Screen.Filter = LOG_TO_STDERR log4perl.appender.Screen.stderr = 1 log4perl.appender.Screen.layout = Log::Log4perl::Layout::PatternLayout -log4perl.appender.Screen.layout.ConversionPattern = %d %6p | %c | %m{chomp}%n +log4perl.appender.Screen.layout.ConversionPattern = [%X{request_id}] %d %6p | %c | %m{chomp}%n log4perl.appender.File = Log::Log4perl::Appender::File log4perl.appender.File.layout = Log::Log4perl::Layout::Mozilla |