From 1a548e6be0318339711dd4e7b539e3a26647265c Mon Sep 17 00:00:00 2001 From: Brian Cully Date: Thu, 16 Nov 2017 16:57:15 +0000 Subject: Use named logging routines. * error/warning/verbose * All logs dump timestamps and PID. --- xmpt | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'xmpt') diff --git a/xmpt b/xmpt index b422e2d..3d7cb3f 100755 --- a/xmpt +++ b/xmpt @@ -186,7 +186,7 @@ sub do_send { # TODO: make write SIGPIPE configurable, but for now just ignore it. local $SIG{PIPE} = sub { - print STDERR "Warning: SIGPIPE received from '@ARGV' while writing in $name step.\n" + warning("SIGPIPE received from '@ARGV' while writing in $name step.\n"); }; print $evalpkg::out $s; } @@ -246,12 +246,22 @@ sub do_recv { } } +sub error { + _l("ERROR: " . shift); +} + +sub warning { + _l("Warning: " . shift); +} + sub verbose { - if ($verbose) { - my $msg = shift; - chomp $msg; - print STDERR strftime('%Y-%m-%d %H:%M:%S', localtime) . " [$$] $msg\n"; - } + _l(shift) if $verbose; +} + +sub _l { + my $msg = shift; + chomp $msg; + print STDERR strftime('%Y-%m-%d %H:%M:%S', localtime) . " [$$] $msg\n"; } sub assert_arg { -- cgit v1.2.3