http://qs321.pair.com?node_id=306748


in reply to When to use logging and why?

As liz and pg have already said reporting and debugging. But I also often need to run my scripts as daemons/services and can't see any output so need to see what is going on (Debugging). Also though, I need to run external programs with command line args which I have got from somewhere else (wrapper type things) I often do something as follows;

my $cmd = "extern_prog.exe -$myarg1 -$myarg2 -$myarg3"; if ($DEBUG >= 9) { &Update_Log($cmd); } `$cmd`; sub Update_Log { my $msg = shift; #write $msg to logfile ... }
type stuff, This lets me copy the exact command out of the log file (with the parameters I added) and run it from the command line to check if I have gotten any funny (un-expected) results. You will not believe how many times I have used this..

-----
Of all the things I've lost in my life, its my mind I miss the most.