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 { ...@@ -238,28 +238,6 @@ sub died_somewhere {
##-----------------[/indicators to the Worker]------------------------------- ##-----------------[/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) 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} # 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 { ...@@ -145,7 +145,7 @@ sub life_cycle {
$self->write_output; $self->write_output;
$job_partial_timing{'WRITE_OUTPUT'} = $partial_stopwatch->get_elapsed(); $job_partial_timing{'WRITE_OUTPUT'} = $partial_stopwatch->get_elapsed();
} else { } 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 { ...@@ -169,7 +169,7 @@ sub life_cycle {
unless( $job->died_somewhere ) { 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 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(); $job->dataflow_output_id();
} }
...@@ -186,6 +186,21 @@ sub life_cycle { ...@@ -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 { sub enter_status {
my ($self, $status) = @_; my ($self, $status) = @_;
...@@ -194,9 +209,25 @@ sub enter_status { ...@@ -194,9 +209,25 @@ sub enter_status {
$job->set_and_update_status( $status ); $job->set_and_update_status( $status );
if(my $worker = $self->worker) { if(my $worker = $self->worker) {
$worker->enter_status( $status ); $worker->set_and_update_status( $status );
} elsif($self->debug) { }
print STDERR "StandaloneJob : $status\n";
$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 { ...@@ -471,12 +502,6 @@ sub param_substitute {
return $self->input_job->param_substitute(@_); return $self->input_job->param_substitute(@_);
} }
sub warning {
my $self = shift @_;
return $self->input_job->warning(@_);
}
sub dataflow_output_id { sub dataflow_output_id {
my $self = shift @_; my $self = shift @_;
......
...@@ -743,12 +743,10 @@ sub set_and_update_status { ...@@ -743,12 +743,10 @@ sub set_and_update_status {
sub enter_status { sub enter_status {
my ($self, $status, $msg) = @_; my ($self, $status) = @_;
$msg ||= ": $status";
if($self->debug) { if($self->debug) {
$self->worker_say( $msg ); $self->worker_say( '-> '.$status );
} }
$self->set_and_update_status( $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