diff options
author | Dylan William Hardison <dylan@hardison.net> | 2018-03-01 03:55:10 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-01 03:55:10 +0100 |
commit | fb85881651195cd97ef1499136e947dd56c3b4f3 (patch) | |
tree | 983c8827473da442fe8b685709eaacf496ba9ee8 /Bugzilla.pm | |
parent | 48f08ef18983729dbdcd1af9468fb4ea1ee25fbe (diff) | |
download | bugzilla-fb85881651195cd97ef1499136e947dd56c3b4f3.tar.gz bugzilla-fb85881651195cd97ef1499136e947dd56c3b4f3.tar.xz |
Bug 1437646 - add support for Log::Log4perl
Diffstat (limited to 'Bugzilla.pm')
-rw-r--r-- | Bugzilla.pm | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/Bugzilla.pm b/Bugzilla.pm index c21b1ad98..a154b174b 100644 --- a/Bugzilla.pm +++ b/Bugzilla.pm @@ -11,6 +11,8 @@ use 5.10.1; use strict; use warnings; +use Bugzilla::Logging; + # We want any compile errors to get to the browser, if possible. BEGIN { # This makes sure we're in a CGI. @@ -97,6 +99,10 @@ sub init_page { binmode STDOUT, ':utf8'; } + if (i_am_cgi()) { + Log::Log4perl::MDC->put(remote_ip => remote_ip()); + } + if (${^TAINT}) { # Some environment variables are not taint safe delete @::ENV{'PATH', 'IFS', 'CDPATH', 'ENV', 'BASH_ENV'}; @@ -380,6 +386,10 @@ sub login { my $authenticated_user = $authorizer->login($type); + if (i_am_cgi()) { + Log::Log4perl::MDC->put(user_id => $authenticated_user->id); + } + # At this point, we now know if a real person is logged in. # Check if a password reset is required @@ -770,9 +780,8 @@ sub local_timezone { # Send messages to syslog for the auditing systems (eg. mozdef) to pick up. sub audit { my ($class, $message) = @_; - openlog('apache', 'cons,pid', 'local4'); - syslog('notice', '[audit] ' . encode_utf8($message)); - closelog(); + state $logger = Log::Log4perl->get_logger("audit"); + $logger->notice(encode_utf8($message)); } # This creates the request cache for non-mod_perl installations. @@ -887,6 +896,8 @@ sub _cleanup { foreach my $signal (qw(TERM PIPE)) { $SIG{$signal} = 'DEFAULT' if $SIG{$signal} && $SIG{$signal} eq 'IGNORE'; } + + Log::Log4perl::MDC->remove(); } sub END { |