I wonder if anybody had any good suggestions to create a comphrehensive log file when running scripts. The log file should contain printed lines send to it but also contain all the warnings and errors from the STDOUT. Is their a good way to do this besides from re-directing my STDOUT in the beginning of a script direclty to a filehandle.
open STDOUT ">whatever.dat";
# Here comes all the coding
I don't want to remove my STDOUT, I just want in parallel capture it in a log file.
The result could be something like this
PRINT INFO 12December2004 "Importing JOB x into database"
PRINT WARNING 12December2004 "Job did already exist"
STDOUT ERROR 12December2004 "No permission to overwrite job"
So instead of having all the time an open filehandle is their another way to just capture when something goes to the STDOUT and then write this into a file. For the print I think I can do this easily with the following subroutine but I don't have an idea to also re-direct STDOUT errors and warnings to that routine
my ($script,$type,$log) = @_;
$logfile = $job_path.'/user/LogFile.txt';
open (LOG, "$logfile") || die "File does not exist\n";