diff options
Diffstat (limited to 'extensions/Push')
-rw-r--r-- | extensions/Push/lib/Backoff.pm | 9 | ||||
-rw-r--r-- | extensions/Push/lib/Config.pm | 5 | ||||
-rw-r--r-- | extensions/Push/lib/Connectors.pm | 28 | ||||
-rw-r--r-- | extensions/Push/lib/Push.pm | 3 |
4 files changed, 20 insertions, 25 deletions
diff --git a/extensions/Push/lib/Backoff.pm b/extensions/Push/lib/Backoff.pm index f0116a2a7..0436cdf14 100644 --- a/extensions/Push/lib/Backoff.pm +++ b/extensions/Push/lib/Backoff.pm @@ -19,6 +19,7 @@ use constant AUDIT_REMOVES => 0; use constant USE_MEMCACHED => 0; use Bugzilla; +use Bugzilla::Logging; use Bugzilla::Util; # @@ -67,9 +68,7 @@ sub reset { my ($self) = @_; $self->{next_attempt_ts} = Bugzilla->dbh->selectrow_array('SELECT NOW()'); $self->{attempts} = 0; - Bugzilla->push_ext->logger->debug( - sprintf("resetting backoff for %s", $self->connector) - ); + INFO( sprintf 'resetting backoff for %s', $self->connector ); } sub inc { @@ -82,8 +81,8 @@ sub inc { $self->{next_attempt_ts} = $date; $self->{attempts} = $attempts; - Bugzilla->push_ext->logger->debug( - sprintf("setting next attempt for %s to %s (attempt %s)", $self->connector, $date, $attempts) + INFO( + sprintf 'setting next attempt for %s to %s (attempt %s)', $self->connector, $date, $attempts ); } diff --git a/extensions/Push/lib/Config.pm b/extensions/Push/lib/Config.pm index 337c2696d..2db95b972 100644 --- a/extensions/Push/lib/Config.pm +++ b/extensions/Push/lib/Config.pm @@ -11,7 +11,7 @@ use 5.10.1; use strict; use warnings; -use Bugzilla; +use Bugzilla::Logging; use Bugzilla::Constants; use Bugzilla::Extension::Push::Option; use Crypt::CBC; @@ -52,7 +52,6 @@ sub option { sub load { my ($self) = @_; my $config = {}; - my $logger = Bugzilla->push_ext->logger; # prime $config with defaults foreach my $rh ($self->options) { @@ -81,7 +80,7 @@ sub load { # done, update self foreach my $name (keys %$config) { my $value = $self->option($name)->{type} eq 'password' ? '********' : $config->{$name}; - $logger->debug(sprintf("%s: set %s=%s\n", $self->{_name}, $name, $value || '')); + TRACE( sprintf "%s: set %s=%s\n", $self->{_name}, $name, $value || '' ); $self->{$name} = $config->{$name}; } } diff --git a/extensions/Push/lib/Connectors.pm b/extensions/Push/lib/Connectors.pm index 75a5083ff..d3c55d3ca 100644 --- a/extensions/Push/lib/Connectors.pm +++ b/extensions/Push/lib/Connectors.pm @@ -11,10 +11,12 @@ use 5.10.1; use strict; use warnings; +use Bugzilla::Logging; use Bugzilla::Extension::Push::Util; use Bugzilla::Constants; use Bugzilla::Util qw(trick_taint); use File::Basename; +use Try::Tiny; sub new { my ($class) = @_; @@ -25,16 +27,15 @@ sub new { $self->{objects} = {}; $self->{path} = bz_locations->{'extensionsdir'} . '/Push/lib/Connector'; - my $logger = Bugzilla->push_ext->logger; foreach my $file (glob($self->{path} . '/*.pm')) { my $name = basename($file); $name =~ s/\.pm$//; next if $name eq 'Base'; if (length($name) > 32) { - $logger->info("Ignoring connector '$name': Name longer than 32 characters"); + WARN("Ignoring connector '$name': Name longer than 32 characters"); } push @{$self->{names}}, $name; - $logger->debug("Found connector '$name'"); + TRACE("Found connector '$name'"); } return $self; @@ -44,7 +45,6 @@ sub _load { my ($self) = @_; return if scalar keys %{$self->{objects}}; - my $logger = Bugzilla->push_ext->logger; foreach my $name (@{$self->{names}}) { next if exists $self->{objects}->{$name}; my $file = $self->{path} . "/$name.pm"; @@ -52,34 +52,30 @@ sub _load { require $file; my $package = "Bugzilla::Extension::Push::Connector::$name"; - $logger->debug("Loading connector '$name'"); + TRACE("Loading connector '$name'"); my $old_error_mode = Bugzilla->error_mode; Bugzilla->error_mode(ERROR_MODE_DIE); - eval { + try { my $connector = $package->new(); $connector->load_config(); $self->{objects}->{$name} = $connector; + } catch { + ERROR("Connector '$name' failed to load: " . clean_error($_)); }; - if ($@) { - $logger->error("Connector '$name' failed to load: " . clean_error($@)); - } Bugzilla->error_mode($old_error_mode); } } sub stop { my ($self) = @_; - my $logger = Bugzilla->push_ext->logger; foreach my $connector ($self->list) { next unless $connector->enabled; - $logger->debug("Stopping '" . $connector->name . "'"); - eval { + TRACE("Stopping '" . $connector->name . "'"); + try { $connector->stop(); + } catch { + ERROR("Connector '" . $connector->name . "' failed to stop: " . clean_error($_)); }; - if ($@) { - $logger->error("Connector '" . $connector->name . "' failed to stop: " . clean_error($@)); - $logger->debug("Connector '" . $connector->name . "' failed to stop: $@"); - } } } diff --git a/extensions/Push/lib/Push.pm b/extensions/Push/lib/Push.pm index 45b9b05dd..670b2aa56 100644 --- a/extensions/Push/lib/Push.pm +++ b/extensions/Push/lib/Push.pm @@ -11,6 +11,7 @@ use 5.10.1; use strict; use warnings; +use Bugzilla::Logging; use Bugzilla::Extension::Push::BacklogMessage; use Bugzilla::Extension::Push::Config; use Bugzilla::Extension::Push::Connectors; @@ -107,7 +108,7 @@ sub push { # if the connector is backlogged, push to the backlog queue if ($is_backlogged) { - $logger->debug("backlogged"); + INFO('connector is backlogged'); my $backlog = Bugzilla::Extension::Push::BacklogMessage->create_from_message($message, $connector); } } |