Add Logger::stop_online_logging().

This commit is contained in:
Daniel Nichter
2013-05-20 14:03:39 -07:00
parent 20c3bd6c29
commit 99592409e6
2 changed files with 20 additions and 6 deletions

View File

@@ -4975,13 +4975,20 @@ sub _log {
return; return;
} }
sub DESTROY { sub stop_online_logging {
my $self = shift; my $self = shift;
if ( $self->online_logging ) { if ( $self->_thread && $self->_thread->is_running() ) {
my @stop :shared = (undef, undef); my @stop :shared = (undef, undef);
$self->_message_queue->enqueue(\@stop); # stop the thread $self->_message_queue->enqueue(\@stop); # stop the thread
$self->_thread->join(); $self->_thread->join();
} }
$self->online_logging(0);
return;
}
sub DESTROY {
my $self = shift;
$self->stop_online_logging();
return; return;
} }
@@ -5365,8 +5372,8 @@ sub main {
$logger->info("pt-agent exit $exit_status, oktorun $oktorun"); $logger->info("pt-agent exit $exit_status, oktorun $oktorun");
# Cause Logger::DESTORY to be called. $logger->stop_online_logging();
$logger = undef; $logger->info('Waiting for logging thread to stop...');
return $exit_status; return $exit_status;
} }

View File

@@ -207,13 +207,20 @@ sub _log {
return; return;
} }
sub DESTROY { sub stop_online_logging {
my $self = shift; my $self = shift;
if ( $self->online_logging ) { if ( $self->_thread && $self->_thread->is_running() ) {
my @stop :shared = (undef, undef); my @stop :shared = (undef, undef);
$self->_message_queue->enqueue(\@stop); # stop the thread $self->_message_queue->enqueue(\@stop); # stop the thread
$self->_thread->join(); $self->_thread->join();
} }
$self->online_logging(0);
return;
}
sub DESTROY {
my $self = shift;
$self->stop_online_logging();
return; return;
} }