diff options
author | Dylan William Hardison <dylan@hardison.net> | 2018-03-20 14:27:33 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-20 14:27:33 +0100 |
commit | 293a5bd57b3a50c5130c299b3f53b357f683a33e (patch) | |
tree | 535ba7d212765aaf1aef8acd2f5b81c13f1eeed9 /extensions/Push | |
parent | 1121193471e2f6f6b7d4e5c27a465f476f7f100f (diff) | |
download | bugzilla-293a5bd57b3a50c5130c299b3f53b357f683a33e.tar.gz bugzilla-293a5bd57b3a50c5130c299b3f53b357f683a33e.tar.xz |
Bug 1447291 - Remove Apache2::Log from PhabBugs/Push in favor of logging framework
Diffstat (limited to 'extensions/Push')
-rw-r--r-- | extensions/Push/lib/Logger.pm | 52 |
1 files changed, 22 insertions, 30 deletions
diff --git a/extensions/Push/lib/Logger.pm b/extensions/Push/lib/Logger.pm index 833cb3b19..5d92010ee 100644 --- a/extensions/Push/lib/Logger.pm +++ b/extensions/Push/lib/Logger.pm @@ -8,53 +8,43 @@ package Bugzilla::Extension::Push::Logger; use 5.10.1; -use strict; -use warnings; +use Moo; +use Bugzilla::Logging; +use Log::Log4perl; use Bugzilla::Extension::Push::Constants; use Bugzilla::Extension::Push::LogEntry; -sub new { - my ($class) = @_; - my $self = {}; - bless($self, $class); - return $self; -} +# If Log4perl then finds that it's being called from a registered wrapper, it +# will automatically step up to the next call frame. +Log::Log4perl->wrapper_register(__PACKAGE__); -sub info { shift->_log_it('INFO', @_) } -sub error { shift->_log_it('ERROR', @_) } -sub debug { shift->_log_it('DEBUG', @_) } +sub info { + my ($this, $message) = @_; + INFO($message); +} -sub debugging { - my ($self) = @_; - return $self->{debug}; +sub error { + my ($this, $message) = @_; + ERROR($message); } -sub _log_it { - require Apache2::Log; - my ($self, $method, $message) = @_; - return if $method eq 'DEBUG' && !$self->debugging; - chomp $message; - if ($ENV{MOD_PERL}) { - Apache2::ServerRec::warn("Push $method: $message"); - } elsif ($ENV{SCRIPT_FILENAME}) { - print STDERR "Push $method: $message\n"; - } else { - print STDERR '[' . localtime(time) ."] $method: $message\n"; - } +sub debug { + my ($this, $message) = @_; + DEBUG($message); } sub result { my ($self, $connector, $message, $result, $data) = @_; $data ||= ''; - $self->info(sprintf( - "%s: Message #%s: %s %s", + my $log_msg = sprintf + '%s: Message #%s: %s %s', $connector->name, $message->message_id, push_result_to_string($result), - $data - )); + $data; + $self->info($log_msg); Bugzilla::Extension::Push::LogEntry->create({ message_id => $message->message_id, @@ -68,4 +58,6 @@ sub result { }); } +sub _build_logger { Log::Log4perl->get_logger(__PACKAGE__); } + 1; |