Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 299688 Details for
Bug 406301
3.20: Log4perl support (keys added to data/params as well) Bugzilla/RH.pm
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
v1 for log4perl logging code added to BZ 3.2
logging_patch (text/plain), 15.86 KB, created by
Noura El hawary
on 2008-03-31 06:32:08 UTC
(
hide
)
Description:
v1 for log4perl logging code added to BZ 3.2
Filename:
MIME Type:
Creator:
Noura El hawary
Created:
2008-03-31 06:32:08 UTC
Size:
15.86 KB
patch
obsolete
>Index: Bugzilla.pm >=================================================================== >RCS file: /cvs/qa/rh_bugzilla_3/Bugzilla.pm,v >retrieving revision 1.8 >diff -p -u -r1.8 Bugzilla.pm >--- Bugzilla.pm 17 Mar 2008 21:41:30 -0000 1.8 >+++ Bugzilla.pm 31 Mar 2008 06:17:01 -0000 >@@ -53,6 +53,25 @@ use File::Basename; > use File::Spec::Functions; > use Safe; > >+# REDHAT EXTENSION BEGIN 406301 >+# add Log4perl support >+use Log::Log4perl; >+use Log::Log4perl::MDC; >+use Time::HiRes; >+use Bugzilla::Constants; >+ >+sub logger { >+ Log::Log4perl::get_logger(""); >+} >+ >+sub log_filename { >+ Log::Log4perl::appender_by_name('LOGFILE')->filename; >+} >+ >+my $t0; >+# REDHAT EXTENSION END 406301 >+ >+ > # This creates the request cache for non-mod_perl installations. > our $_request_cache = {}; > >@@ -175,6 +194,28 @@ sub init_page { > print $t_output . "\n"; > exit; > } >+ >+ >+ # REDHAT EXTENSION BEGIN 406301 >+ # add Log4perl support >+ $t0 = [Time::HiRes::gettimeofday]; >+ eval { >+ my $conf = Bugzilla->params->{log4perl_config}; >+ Log::Log4perl::init_once(\$conf) >+ }; >+ if (my $e = $@) { >+ warn "config failed to load: $e"; >+ my $conf = Bugzilla::Constants::LOG4PERL_DEFAULT_CONFIG; >+ Log::Log4perl::init_once(\$conf); # should _always_ work >+ } >+ # code these in the log layout pattern as %X{<key>} >+ Log::Log4perl::MDC->put( script => $0 ); >+ Log::Log4perl::MDC->put( http_x_forwarded_for => $ENV{HTTP_X_FORWARDED_FOR} ); >+ Log::Log4perl::MDC->put( remote_addr => $ENV{REMOTE_ADDR} ); >+ # start a log message. the begin section should ensure >+ # that the config is loaded >+ Log::Log4perl::get_logger("")->debug("START"); >+ # REDHAT EXTENSION END 406301 > } > > init_page() if !$ENV{MOD_PERL}; >@@ -282,7 +323,17 @@ sub login { > else { > $class->set_user($authenticated_user); > } >- >+ >+ # REDHAT EXTENSION BEGIN 406301 >+ # Log4perl support >+ # code these in the log layout pattern as %X{<key>} >+ Log::Log4perl::MDC->put( user_id => $class->user->id ); >+ Log::Log4perl::MDC->put( user_name => $class->user->name ); >+ Log::Log4perl::MDC->put( user_login => $class->user->login ); >+ # REDHAT EXTENSION END 406301 >+ >+ >+ > return $class->user; > } > >@@ -496,6 +547,13 @@ sub _cleanup { > $dbh->bz_rollback_transaction() if $dbh->bz_in_transaction; > $dbh->disconnect; > } >+ >+ # REDHAT EXTENSION BEGIN 406301 >+ # Log4perl support >+ my $elapsed = Time::HiRes::tv_interval ( $t0, [Time::HiRes::gettimeofday]); >+ Log::Log4perl::get_logger("")->debug(sprintf("FINISH ELAPSED=%8.4f", $elapsed)); >+ # REDHAT EXTENSION END 406301 >+ > undef $_request_cache; > } > >Index: Bugzilla/Constants.pm >=================================================================== >RCS file: /cvs/qa/rh_bugzilla_3/Bugzilla/Constants.pm,v >retrieving revision 1.8 >diff -p -u -r1.8 Constants.pm >--- Bugzilla/Constants.pm 17 Mar 2008 21:48:07 -0000 1.8 >+++ Bugzilla/Constants.pm 31 Mar 2008 06:17:20 -0000 >@@ -426,6 +426,18 @@ use constant MAX_COMPONENT_SIZE => 64; > # Maximum length allowed for free text fields. > use constant MAX_FREETEXT_LENGTH => 255; > >+# REDHAT EXTENSION BEGIN 406301 >+# default log4perl config >+use constant LOG4PERL_DEFAULT_CONFIG => q( >+log4perl.rootLogger=DEBUG, LOGFILE >+log4perl.appender.LOGFILE=Log::Log4perl::Appender::File >+log4perl.appender.LOGFILE.filename=/tmp/bz.log >+log4perl.appender.LOGFILE.mode=append >+log4perl.appender.LOGFILE.layout=PatternLayout >+log4perl.appender.LOGFILE.layout.ConversionPattern=[%d.%r] [%H;%P] [%p] [%X{script}:%X{userid}:%X{username}:%X{userlogin}] [%l] - %m%n >+); >+# REDHAT EXTENSION END 406301 >+ > sub bz_locations { > # We know that Bugzilla/Constants.pm must be in %INC at this point. > # So the only question is, what's the name of the directory >Index: Bugzilla/Config/Admin.pm >=================================================================== >RCS file: /cvs/qa/rh_bugzilla_3/Bugzilla/Config/Admin.pm,v >retrieving revision 1.1.1.1 >diff -p -u -r1.1.1.1 Admin.pm >--- Bugzilla/Config/Admin.pm 19 Nov 2007 22:11:21 -0000 1.1.1.1 >+++ Bugzilla/Config/Admin.pm 31 Mar 2008 06:17:30 -0000 >@@ -34,6 +34,7 @@ package Bugzilla::Config::Admin; > use strict; > > use Bugzilla::Config::Common; >+use Bugzilla::Constants; > > $Bugzilla::Config::Admin::sortkey = "01"; > >@@ -62,7 +63,17 @@ sub get_param_list { > name => 'supportwatchers', > type => 'b', > default => 0 >- } ); >+ }, >+ >+ # REDHAT EXTENSION BEGIN 406301 >+ # Log4perl param >+ { >+ name => 'log4perl_config', >+ type => 'l', >+ default => Bugzilla::Constants::LOG4PERL_DEFAULT_CONFIG, >+ } >+ # REDHAT EXTENSION END 406301 >+ ); > return @param_list; > } > >Index: template/en/default/admin/params/admin.html.tmpl >=================================================================== >RCS file: /cvs/qa/rh_bugzilla_3/template/en/default/admin/params/admin.html.tmpl,v >retrieving revision 1.1.1.1 >diff -p -u -r1.1.1.1 admin.html.tmpl >--- template/en/default/admin/params/admin.html.tmpl 19 Nov 2007 22:11:21 -0000 1.1.1.1 >+++ template/en/default/admin/params/admin.html.tmpl 31 Mar 2008 06:17:50 -0000 >@@ -23,6 +23,9 @@ > desc = "Set up account policies" > %] > >+[%# REDHAT EXTENSION 406301 >+ log4perl_config param description >+%] > [% param_descs = { > allowbugdeletion => "The pages to edit products and components can delete all " _ > "associated $terms.bugs when you delete a product (or component). " _ >@@ -41,5 +44,8 @@ > > supportwatchers => "Support one user watching (ie getting copies of all related " _ > "email about) another's ${terms.bugs}. Useful for people going on " _ >- "vacation, and QA folks watching particular developers' ${terms.bugs}." } >-%] >\ No newline at end of file >+ "vacation, and QA folks watching particular developers' ${terms.bugs}.", >+ >+ log4perl_config => "Enable logging of Web UI and XMLRPC requests by entering the log4perl " _ >+ "conf file in the text box."} >+%] >Index: show_bug.cgi >=================================================================== >RCS file: /cvs/qa/rh_bugzilla_3/show_bug.cgi,v >retrieving revision 1.1.1.1 >diff -p -u -r1.1.1.1 show_bug.cgi >--- show_bug.cgi 19 Nov 2007 22:11:21 -0000 1.1.1.1 >+++ show_bug.cgi 31 Mar 2008 06:18:36 -0000 >@@ -37,6 +37,11 @@ my $vars = {}; > > my $user = Bugzilla->login(); > >+# REDHAT EXTENSION BEGIN 406301 >+my $logger = Bugzilla->logger; >+$logger->debug("starting. CGI input parameters: ". $cgi->query_string); >+# REDHAT EXTENSION END 406301 >+ > # Editable, 'single' HTML bugs are treated slightly specially in a few places > my $single = !$cgi->param('format') > && (!$cgi->param('ctype') || $cgi->param('ctype') eq 'html'); >@@ -46,6 +51,9 @@ if (!$cgi->param('id') && $single) { > print Bugzilla->cgi->header(); > $template->process("bug/choose.html.tmpl", $vars) || > ThrowTemplateError($template->error()); >+ # REDHAT EXTENSION BEGIN 406301 >+ $logger->debug("done. calling bug/choose.html.tmpl"); >+ # REDHAT EXTENSION END 406301 > exit; > } > >@@ -141,3 +149,8 @@ print $cgi->header($format->{'ctype'}); > > $template->process("$format->{'template'}", $vars) > || ThrowTemplateError($template->error()); >+ >+# REDHAT EXTENSION BEGIN 406301 >+$logger->debug("done"); >+# REDHAT EXTENSION END 406301 >+ >Index: process_bug.cgi >=================================================================== >RCS file: /cvs/qa/rh_bugzilla_3/process_bug.cgi,v >retrieving revision 1.20 >diff -p -u -r1.20 process_bug.cgi >--- process_bug.cgi 26 Mar 2008 19:07:33 -0000 1.20 >+++ process_bug.cgi 31 Mar 2008 06:18:47 -0000 >@@ -62,6 +62,11 @@ use Bugzilla::Status; > > use Storable qw(dclone); > >+# REDHAT EXTENSION BEGIN 406301 >+my $logger = Bugzilla->logger; >+$logger->debug("starting"); >+# REDHAT EXTENSION END 406301 >+ > my $user = Bugzilla->login(LOGIN_REQUIRED); > > my $cgi = Bugzilla->cgi; >@@ -196,6 +201,9 @@ if (defined $cgi->param('delta_ts') > # Warn the user about the mid-air collision and ask them what to do. > $template->process("bug/process/midair.html.tmpl", $vars) > || ThrowTemplateError($template->error()); >+ # REDHAT EXTENSION BEGIN 406301 >+ $logger->debug("done. calling bug/process/midair.html.tmpl"); >+ # REDHAT EXTENSION END 406301 > exit; > } > >@@ -480,6 +488,9 @@ if ($move_action eq Bugzilla->params->{' > $template->process("global/footer.html.tmpl", $vars) > || ThrowTemplateError($template->error()); > } >+ # REDHAT EXTENSION END 406301 >+ $logger->debug("done. calling bug/show.xml.tmpl"); >+ # REDHAT EXTENSION END 406301 > exit; > } > >@@ -641,7 +652,9 @@ elsif ($action eq 'next_bug') { > > $template->process("bug/show.html.tmpl", $vars) > || ThrowTemplateError($template->error()); >- >+ # REDHAT EXTENSION END 406301 >+ $logger->debug("done. calling bug/show.html.tmpl"); >+ # REDHAT EXTENSION END 406301 > exit; > } > } >@@ -654,7 +667,9 @@ elsif ($action eq 'next_bug') { > > $template->process("bug/show.html.tmpl", $vars) > || ThrowTemplateError($template->error()); >- >+ # REDHAT EXTENSION END 406301 >+ $logger->debug("done. calling bug/show.html.tmpl"); >+ # REDHAT EXTENSION END 406301 > exit; > } > } elsif ($action ne 'nothing') { >@@ -668,5 +683,8 @@ unless (Bugzilla->usage_mode == USAGE_MO > $template->process("global/footer.html.tmpl", $vars) > || ThrowTemplateError($template->error()); > } >+# REDHAT EXTENSION BEGIN 406301 >+$logger->debug("done."); >+# REDHAT EXTENSION END 406301 > > 1; >Index: buglist.cgi >=================================================================== >RCS file: /cvs/qa/rh_bugzilla_3/buglist.cgi,v >retrieving revision 1.12 >diff -p -u -r1.12 buglist.cgi >--- buglist.cgi 18 Mar 2008 14:16:08 -0000 1.12 >+++ buglist.cgi 31 Mar 2008 06:18:57 -0000 >@@ -56,6 +56,11 @@ my $template = Bugzilla->template; > my $vars = {}; > my $buffer = $cgi->query_string(); > >+# REDHAT EXTENSION BEGIN 406301 >+my $logger = Bugzilla->logger; >+$logger->debug("CGI input parameters: $buffer"); >+# REDHAT EXTENSION END 406301 >+ > # We have to check the login here to get the correct footer if an error is > # thrown and to prevent a logged out user to use QuickSearch if 'requirelogin' > # is turned 'on'. >@@ -947,10 +952,17 @@ $dbh = Bugzilla->switch_to_shadow_db(); > $::SIG{TERM} = 'DEFAULT'; > $::SIG{PIPE} = 'DEFAULT'; > >+# REDHAT EXTENSION BEGIN 406301 >+$logger->debug("sql query before execution: [ $query ]"); >+# REDHAT EXTENSION END 406301 >+ > # Execute the query. > my $buglist_sth = $dbh->prepare($query); > $buglist_sth->execute(); > >+# REDHAT EXTENSION BEGIN 406301 >+$logger->debug("sql query executed"); >+# REDHAT EXTENSION END 406301 > > ################################################################################ > # Results Retrieval >Index: request.cgi >=================================================================== >RCS file: /cvs/qa/rh_bugzilla_3/request.cgi,v >retrieving revision 1.3 >diff -p -u -r1.3 request.cgi >--- request.cgi 14 Feb 2008 03:17:47 -0000 1.3 >+++ request.cgi 31 Mar 2008 06:19:05 -0000 >@@ -111,6 +111,11 @@ sub queue { > my $status = validateStatus($cgi->param('status')); > my $form_group = validateGroup($cgi->param('group')); > >+ # REDHAT EXTENSION BEGIN 406301 >+ my $logger = Bugzilla->logger; >+ $logger->debug("CGI input parameters: " . $cgi->query_string); >+ # REDHAT EXTENSION END 406301 >+ > my $query = > # Select columns describing each flag, the bug/attachment on which > # it has been set, who set it, and of whom they are requesting it. >@@ -296,8 +301,17 @@ sub queue { > # Pass the query to the template for use when debugging this script. > $vars->{'query'} = $query; > $vars->{'debug'} = $cgi->param('debug') ? 1 : 0; >+ >+ # REDHAT EXTENSION BEGIN 406301 >+ $logger->debug("sql query before execution: [ $query ]"); >+ # REDHAT EXTENSION END 406301 > > my $results = $dbh->selectall_arrayref($query); >+ >+ # REDHAT EXTENSION BEGIN 406301 >+ $logger->debug("sql query executed"); >+ # REDHAT EXTENSION END 406301 >+ > my @requests = (); > foreach my $result (@$results) { > my @data = @$result; >Index: Bugzilla/BugMail.pm >=================================================================== >RCS file: /cvs/qa/rh_bugzilla_3/Bugzilla/BugMail.pm,v >retrieving revision 1.12 >diff -p -u -r1.12 BugMail.pm >--- Bugzilla/BugMail.pm 17 Mar 2008 21:48:07 -0000 1.12 >+++ Bugzilla/BugMail.pm 31 Mar 2008 06:19:15 -0000 >@@ -65,6 +65,10 @@ use constant REL_NAMES => { > REL_GLOBAL_WATCHER, "GlobalWatcher" > }; > >+# REDHAT EXTENSION BEGIN 406301 >+my $logger = Bugzilla->logger; >+# REDHAT EXTENSION END 406301 >+ > # We use this instead of format because format doesn't deal well with > # multi-byte languages. > sub multiline_sprintf { >@@ -112,6 +116,10 @@ sub three_columns { > sub Send { > my ($id, $forced) = (@_); > >+ # REDHAT EXTENSION BEGIN 406301 >+ $logger->debug("bug_id: $id"); >+ # REDHAT EXTENSION END 406301 >+ > my @headerlist; > my %defmailhead; > my %fielddescription; >@@ -553,6 +561,10 @@ sub sendMail { > $diffRef, $newcomments, $anyprivate, $isnew, > $id, $watchingRef) = @_; > >+ # REDHAT EXTENSION BEGIN 406301 >+ $logger->debug("user id: " . $user->id); >+ # REDHAT EXTENSION END 406301 >+ > my %values = %$valueRef; > my @headerlist = @$hlRef; > my %mailhead = %$dmhRef; >Index: report.cgi >=================================================================== >RCS file: /cvs/qa/rh_bugzilla_3/report.cgi,v >retrieving revision 1.1.1.1 >diff -p -u -r1.1.1.1 report.cgi >--- report.cgi 19 Nov 2007 22:11:21 -0000 1.1.1.1 >+++ report.cgi 31 Mar 2008 06:19:29 -0000 >@@ -35,6 +35,11 @@ my $template = Bugzilla->template; > my $vars = {}; > my $buffer = $cgi->query_string(); > >+# REDHAT EXTENSION BEGIN 406301 >+my $logger = Bugzilla->logger; >+$logger->debug("CGI input parameters: $buffer"); >+# REDHAT EXTENSION END 406301 >+ > # Go straight back to query.cgi if we are adding a boolean chart. > if (grep(/^cmd-/, $cgi->param())) { > my $params = $cgi->canonicalise_query("format", "ctype"); >@@ -146,8 +151,16 @@ my $query = $search->getSQL(); > $::SIG{TERM} = 'DEFAULT'; > $::SIG{PIPE} = 'DEFAULT'; > >+# REDHAT EXTENSION BEGIN 406301 >+$logger->debug("sql query before execution: [ $query ]"); >+# REDHAT EXTENSION END 406301 >+ > my $results = $dbh->selectall_arrayref($query); > >+# REDHAT EXTENSION BEGIN 406301 >+$logger->debug("sql query executed"); >+# REDHAT EXTENSION END 406301 >+ > # We have a hash of hashes for the data itself, and a hash to hold the > # row/col/table names. > my %data; >Index: Bugzilla/Error.pm >=================================================================== >RCS file: /cvs/qa/rh_bugzilla_3/Bugzilla/Error.pm,v >retrieving revision 1.2 >diff -p -u -r1.2 Error.pm >--- Bugzilla/Error.pm 28 Jan 2008 04:46:17 -0000 1.2 >+++ Bugzilla/Error.pm 31 Mar 2008 06:19:40 -0000 >@@ -114,10 +114,26 @@ sub _throw_error { > } > > sub ThrowUserError { >+ # REDHAT EXTENSION BEGIN 406301 >+ eval { >+ # eval so that the error logging doesn't >+ # impede the error reporting to UI >+ local $" = ', '; >+ Bugzilla->logger()->error("@_"); >+ }; >+ # REDHAT EXTENSION END 406301 > _throw_error("global/user-error.html.tmpl", @_); > } > > sub ThrowCodeError { >+ # REDHAT EXTENSION BEGIN 406301 >+ eval { >+ # eval so that the error logging doesn't >+ # impede the error reporting to UI >+ local $" = ', '; >+ Bugzilla->logger()->error("@_"); >+ }; >+ # REDHAT EXTENSION END 406301 > _throw_error("global/code-error.html.tmpl", @_); > } > >@@ -125,6 +141,15 @@ sub ThrowTemplateError { > my ($template_err) = @_; > my $dbh = Bugzilla->dbh; > >+ # REDHAT EXTENSION BEGIN 406301 >+ eval { >+ # eval so that the error logging doesn't >+ # impede the error reporting to UI >+ local $" = ', '; >+ Bugzilla->logger()->error("@_"); >+ }; >+ # REDHAT EXTENSION END 406301 >+ > # Make sure the transaction is rolled back (if supported). > $dbh->bz_rollback_transaction() if $dbh->bz_in_transaction(); >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
dkl
: review-
Actions:
View
|
Diff
Attachments on
bug 406301
:
299688
|
299881