This is pretty weird. Why would you log errors this way?

There is already a lot of very good work into logging things with CGI::Carp

I don't know if you are master hacker and you've got some spooky stuff going on. But if you're not- and you don't- Then I would suggest to use CGI:Carp and stay clear of re-inventing the wheel.

BEGIN { use CGI::Carp qw(carpout); open(LOG, ">>/var/log/yourlogfile") + or die("Unable to open yourlogfile: $!\n"); carpout(LOG);}

Yes, I know at first hand it doesn't seem to replace anything. But, you could always record to a log, and run a script on cron that greps out sections to flat files- whatever.

If you must though... CPAN has IO::Capture::Stderr - Capture all output sent to STDERR. No perl minion should feel safe even going to take a sh&t before I searching CPAN for the right toilet paper to wipe your a55. And it's free. Like the one you steel from work.

Hope this helps.. ?


In reply to Re: Logging Errors by leocharre
in thread Logging Errors by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.