Is redirecting STDOUT and STDERR of the invoking shell an option?
(perl -le 'print "foo"; print STDERR "bar"' | sed 's,^,OUT ,' | tee -a
+ log.stdout ) 2>&1 1>/dev/tty | sed 's,^,ERR ,' | tee -a log.stderr
Of course that doesn't work if there's no tty.
update: replace /dev/tty with /dev/null in that case. Or better, if you don't need output to the terminal
(perl -le 'print "foo"; print STDERR "bar"' | sed 's,^,OUT ,') 2>&1 1>
+>log.stdout | sed 's,^,ERR ,' >> log.stderr
--shmem
_($_=" "x(1<<5)."?\n".q·/)Oo. G°\ /
/\_¯/(q /
---------------------------- \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}