Skip to content
Snippets Groups Projects
Commit 19168ee4 authored by Leo Gordon's avatar Leo Gordon
Browse files

improved and simplified logging/reporting

parent e04af84f
No related branches found
No related tags found
No related merge requests found
......@@ -238,28 +238,6 @@ sub died_somewhere {
##-----------------[/indicators to the Worker]-------------------------------
=head2 warning
Description: records a non-error message in 'log_message' table linked to the current job
=cut
sub warning {
my ($self, $msg, $is_error) = @_;
$is_error //= 0;
my $job_adaptor = $self->adaptor;
if( $is_error or !$job_adaptor) {
my $class = $is_error ? 'Error' : 'Warning';
print STDERR "Job${class}: $msg\n";
}
if( $job_adaptor ) {
$job_adaptor->db->get_LogMessageAdaptor()->store_job_message($self->dbID, $msg, $is_error);
}
}
sub fan_cache { # a self-initializing getter (no setting)
# Returns a hash-of-lists { 2 => [list of jobs waiting to be funneled into 2], 3 => [list of jobs waiting to be funneled into 3], etc}
......
......@@ -145,7 +145,7 @@ sub life_cycle {
$self->write_output;
$job_partial_timing{'WRITE_OUTPUT'} = $partial_stopwatch->get_elapsed();
} else {
print STDERR "\n!!! *no* WRITE_OUTPUT requested, so there will be no AUTOFLOW\n" if($self->debug);
$self->say_with_header( ": *no* WRITE_OUTPUT requested, so there will be no AUTOFLOW" );
}
};
......@@ -169,7 +169,7 @@ sub life_cycle {
unless( $job->died_somewhere ) {
if( $self->execute_writes and $job->autoflow ) { # AUTOFLOW doesn't have its own status so will have whatever previous state of the job
print STDERR "\njob ".$job->dbID." : AUTOFLOW input->output\n" if($self->debug);
$self->say_with_header( ': AUTOFLOW input->output' );
$job->dataflow_output_id();
}
......@@ -186,6 +186,21 @@ sub life_cycle {
}
sub say_with_header {
my ($self, $msg, $important) = @_;
$important //= $self->debug();
if($important) {
if(my $worker = $self->worker) {
$worker->worker_say( $msg );
} else {
print STDERR "StandaloneJob $msg\n";
}
}
}
sub enter_status {
my ($self, $status) = @_;
......@@ -194,9 +209,25 @@ sub enter_status {
$job->set_and_update_status( $status );
if(my $worker = $self->worker) {
$worker->enter_status( $status );
} elsif($self->debug) {
print STDERR "StandaloneJob : $status\n";
$worker->set_and_update_status( $status );
}
$self->say_with_header( '-> '.$status );
}
sub warning {
my ($self, $msg, $is_error) = @_;
$is_error //= 0;
chomp $msg;
$self->say_with_header( ($is_error ? 'Fatal' : 'Warning')." : $msg" );
my $job = $self->input_job;
if(my $job_adaptor = $job->adaptor) {
$job_adaptor->db->get_LogMessageAdaptor()->store_job_message($job->dbID, $msg, $is_error);
}
}
......@@ -471,12 +502,6 @@ sub param_substitute {
return $self->input_job->param_substitute(@_);
}
sub warning {
my $self = shift @_;
return $self->input_job->warning(@_);
}
sub dataflow_output_id {
my $self = shift @_;
......
......@@ -743,12 +743,10 @@ sub set_and_update_status {
sub enter_status {
my ($self, $status, $msg) = @_;
$msg ||= ": $status";
my ($self, $status) = @_;
if($self->debug) {
$self->worker_say( $msg );
$self->worker_say( '-> '.$status );
}
$self->set_and_update_status( $status );
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment