From 1e807e07c7f4c77bef652757fdd13eebe38932bb Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jan=20Kr=C3=BCger?= Date: Wed, 24 Nov 2010 18:13:27 +0100 Subject: [PATCH] jobd: unify error/status reporting MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Make more places use the error() function for reporting messages, and also introduce/use ferror() to output sprintf-formatted messages. Signed-off-by: Jan Krüger --- jobd/jobd.pl | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/jobd/jobd.pl b/jobd/jobd.pl index 0d3a3af..b21a511 100755 --- a/jobd/jobd.pl +++ b/jobd/jobd.pl @@ -210,7 +210,7 @@ sub reap_hanging_jobs { if (defined($_->{'started_at'}) && (time - $_->{'started_at'}) > $kill_after) { $_->{'finished'} = 1; kill 'KILL', -($_->{'pid'}); - print STDERR _job_name($_) ." KILLED due to timeout\n"; + error(_job_name($_) ." KILLED due to timeout"); push @jobs_killed, _job_name($_); } } @@ -254,7 +254,7 @@ sub run_queue { $jobs_skipped = 0; @jobs_killed = (); if ($progress) { - printf STDERR ts() ."--- Processing %d queued jobs\n", scalar(@queue); + error("--- Processing %d queued jobs", scalar(@queue)); } $SIG{'INT'} = \&handle_softexit; $SIG{'TERM'} = \&handle_exit; @@ -263,7 +263,7 @@ sub run_queue { my $proceed_immediately = reap_finished_jobs(); # Status output if ($progress && (time - $last_progress) >= 60) { - printf STDERR ts() ."status: %d queued, %d running, %d finished, %d skipped, %d killed\n", scalar(@queue), scalar(@running), $jobs_executed, $jobs_skipped, scalar(@jobs_killed); + ferror("STATUS: %d queued, %d running, %d finished, %d skipped, %d killed", scalar(@queue), scalar(@running), $jobs_executed, $jobs_skipped, scalar(@jobs_killed)); if (@running) { my @run_status; for (@running) { @@ -282,7 +282,7 @@ sub run_queue { run_job(shift(@queue)) if @queue; } if ($progress) { - printf STDERR ts() ."--- Queue processed. %d jobs executed, %d skipped, %d killed.\n", $jobs_executed, $jobs_skipped, scalar(@jobs_killed); + ferror("--- Queue processed. %d jobs executed, %d skipped, %d killed.", $jobs_executed, $jobs_skipped, scalar(@jobs_killed)); } } @@ -306,7 +306,10 @@ sub run_perpetually { ######### Helpers {{{1 sub error($) { - print STDERR shift()."\n"; + print STDERR ts().shift()."\n"; +} +sub ferror(@) { + error(sprintf(@_)); } sub fatal($) { error(shift); -- 2.11.4.GIT