Re: Logging STDERR and other output



On 30 Aug 2007 at 10:07, Mumia W. wrote:

On 08/30/2007 09:37 AM, Beginner wrote:
[...]

I tried the INIT option and that worked also and I liked the fact
that my `perl -c myscript.pl` sent it's output to screen and not my
log file and I can use a scalar for logfile.

q1) Does this still give me the effect of getting any errors from the
other modules directed to our $logfile?


Probably not. There's no better way than to try it and see if it works.
Read "perldoc perlmod" too.

Not sure how conclusive this is but if I put

print STDERR "Just testing\n";

in one of the used modules it does get logged to the logfile. However
is appears at the top of the log!! Before all the other messages even
thought that module's functions are not called to near the end.

q2) Will our $logfile now be a shared variable across all my modules?
Try it and see.

No. It's not.

q3) The $debug/verbose question: Will I have to pass subroutines in
other modules the $debug value if I am going to ask for more output,
or if I do the same to $debug as I did with $logfile, use our instead
of my. Will that allow those subroutines to check if debug is
enabled?

Most people create a logging module if they want total control over
logging. That module might have a packag $debug_level variable that
determines how much information is logged.

However, the Perl error and warning messages don't fit your logging
model, so you'll probably have to write something yourself or find it on
CPAN.

Log::Handler looks pretty comprehensive.
Thanx for the tips.
Dp.

.



Relevant Pages

  • Re: Logging STDERR and other output
    ... I tried the INIT option and that worked also and I liked the fact that my `perl -c myscript.pl` sent it's output to screen and not my log file and I can use a scalar for logfile. ... other modules the $debug value if I am going to ask for more output, or if I do the same to $debug as I did with $logfile, use our instead of my. ... Most people create a logging module if they want total control over logging. ...
    (perl.beginners)
  • Re: problems appending an entry to a logfile
    ... (given ym perl ability. ... localtime() returns a string containing the local time. ... i would like my logfile to look like ... perldoc -q "output of a command" ...
    (comp.lang.perl.misc)
  • Re: I need a custom script to extract data from my web logs.
    ... > assume this is some add-on package for perl. ... If you like to have the entries in the order of the logfile, ... sort to sort for date again after the loop ...
    (comp.unix.shell)
  • Re: Unable to debug Perl script
    ... I needed to debug this script. ... If you still get the error, reduce it to the shortest program you ... This is perl, v5.8.8 built for i386-linux-thread-multi ...
    (comp.lang.perl.misc)
  • Re: Badly placed ()s.
    ... You can help yourself debug this problem by looking up the ... Perl yourself. ... You should include the reason for the failure in your diag message. ... print $tmpLine; ...
    (comp.lang.perl.misc)