note
Dominus
Something similar I often do in CGI programs and other utilities that are not attached to the terminal:<p>
<code>
BEGIN {
open STDERR, ">", "/tmp/$0-$$.log";
}
</code>
and then all die and warn messages go to the log file in /tmp.<p>
To get this to work with <code>Sys::Syslog</code> you would need a little more machinery:<p>
<code>
BEGIN {
sub SLH::PRINT { syslog("err", $_[1]) }
sub SLH::TIEHANDLE { return bless ["dummy object"] => "SLH" }
tie *STDERR => "SLH";
}
</code>
And then everything written to STDERR gets passed along to syslog.<p>
Disclaimer 1: I didn't actually try this.<p>
Disclaimer 2: I never, ever use software written by Eric Allman.<p>
<!-- Node text goes above. Div tags should contain sig only -->
<div class="pmsig"><div class="pmsig-3737">
<p>
--<br><font size="-2">
<a href="mailto:mjd-www-perlmonks+@plover.com">Mark Dominus</a><br>
<a href="http://perl.plover.com">Perl Paraphernalia</a><br></font>
</div></div>
647874
647874