I'm trying to hack in better logging for a test program that I didn't write. I want all lines of STDERR output to have timestamps, but if possible I want to leave STDOUT alone. I also want one file (all.txt) to log both stdout and stderr (either with or without STDERR timestamps), and a file dedicated to STDERR output (errors.txt, with timestamps)
Also, I don't care whether anything is echoed to the terminal or not. This is a batch-style program.
I did look at rsyslog and that might come in later, but this is a solution I should be able to hack in real quick...at least, if I knew more about output redirection. I read a bunch of similar questions but apparently nothing with this exact situation.
I think in order to add timestamps to stderr output, I want to use a pipe and the technique from this question: http://serverfault.com/questions/310098/adding-a-timestamp-to-bash-script-log
What is the cleanest solution here? Note that I have RHEL5 systems that are on bash 3.2.25.
+----stdout-------------------+ / \ test.pl --+ +--> all.txt \ / +----stderr | add_timestamps -+----> errors.txt