diff options
Diffstat (limited to 'Bugzilla/Logging.pm')
-rw-r--r-- | Bugzilla/Logging.pm | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/Bugzilla/Logging.pm b/Bugzilla/Logging.pm index 769485c86..f334435fc 100644 --- a/Bugzilla/Logging.pm +++ b/Bugzilla/Logging.pm @@ -10,21 +10,30 @@ use 5.10.1; use strict; use warnings; -use Log::Log4perl; +use Log::Log4perl qw(:easy); use Log::Log4perl::MDC; -use File::Spec::Functions qw(rel2abs); +use File::Spec::Functions qw(rel2abs catfile); use Bugzilla::Constants qw(bz_locations); use English qw(-no_match_vars $PROGRAM_NAME); +use Taint::Util qw(untaint); -sub is_interactive { - return not exists $ENV{SERVER_SOFTWARE} +sub logfile { + my ($class, $name) = @_; + + my $file = rel2abs(catfile(bz_locations->{logsdir}, $name)); + untaint($file); + return $file; +} + +sub fields { + return Log::Log4perl::MDC->get_context->{fields} //= {}; } BEGIN { my $file = $ENV{LOG4PERL_CONFIG_FILE} // 'log4perl-syslog.conf'; Log::Log4perl::Logger::create_custom_level('NOTICE', 'WARN', 5, 2); Log::Log4perl->init(rel2abs($file, bz_locations->{confdir})); - Log::Log4perl->get_logger(__PACKAGE__)->trace("logging enabled in $PROGRAM_NAME"); + TRACE("logging enabled in $PROGRAM_NAME"); } # this is copied from Log::Log4perl's :easy handling, |