Package: moreutils
Version: 0.47
Severity: wishlist

chronic is pretty nice, thanks!

I'm curious if you'd consider adding an option to also log to a specified file
in all cases.

I could see wanting a full log file of a cron job, but only output to cron on
errors.

Something like:

  chronic --log-output /var/log/foo.log /usr/bin/foo

Would always log stderr and stdout to /var/log/foo.log, regardless of exit
status or error, in addition to it's usual behavior of only outputting on error.

Proof-of-concept patch, which would obviously require argument processing and
probably could be written much better:

--- /usr/bin/chronic    2012-06-25 13:33:06.000000000 -0700
+++ chronic     2013-04-18 13:06:13.802819115 -0700
@@ -44,16 +44,20 @@
 my $h = IPC::Run::start \@ARGV, \*STDIN, \$out, \$err;
 $h->finish;
 my $ret=$h->full_result;
+open(LOGFILE, '>>/tmp/foo.log');
 
 if ($ret >> 8) { # child failed
        showout();
+       showout_log();
        exit ($ret >> 8);
 }
 elsif ($ret != 0) { # child killed by signal
        showout();
+       showout_log();
        exit 1;
 }
 else {
+       showout_log();
        exit 0;
 }
 
@@ -61,3 +65,10 @@
        print STDOUT $out;
        print STDERR $err;
 }
+
+sub showout_log {
+       print LOGFILE $out;
+       print LOGFILE $err;
+}
+
+close(LOGFILE);

-- System Information:
Debian Release: 7.0
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'testing'), (500, 'stable'), (120, 
'unstable'), (110, 'experimental')
Architecture: i386 (i686)

Kernel: Linux 3.2.0-4-686-pae (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages moreutils depends on:
ii  libc6            2.13-38
ii  libipc-run-perl  0.92-1
ii  perl             5.14.2-20

moreutils recommends no packages.

Versions of packages moreutils suggests:
ii  libtime-duration-perl  1.06-3
ii  libtimedate-perl       1.2000-1

-- no debconf information


-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to