While implementing a new
Log::Dispatch output channel called
Log::Dispatch::Perl (which is on its way to CPAN, but also available from
http://www.liz.nl/CPAN/), I found that I cannot conveniently "lose" a number of levels of the message created by Carp::longmess, as seen if you do a Carp::confess.
The documentation says:
Packages claim that there won't be errors on calls to or from packages explicitly marked as safe by inclusion in @CARP_NOT, or (if that array is empty) @ISA.
Ok, so I added:
our @CARP_NOT = ('Log::Dispatch::Output','Log::Dispatch');
to my Log::Dispatch::Perl code. But a Carp::confess still lists levels with these modules:
use Log::Dispatch::Perl;
my $dispatcher = Log::Dispatch->new;
my $channel = Log::Dispatch::Perl->new( qw(name default min_level debu
+g) );
$dispatcher->add( $channel );
$dispatcher->alert( 'This is an alert' );
__END__
This is an alert
Log::Dispatch::Output::log('undef','level','alert','name','def
+ault','message','This is an alert') called at /usr/local/lib/perl5/si
+te_perl/5.8.3/Log/Dispatch.pm line 95
Log::Dispatch::_log_to('Log::Dispatch=HASH(0xfc578)','level','
+alert','name','default','message','This is an alert') called at /usr/
+local/lib/perl5/site_perl/5.8.3/Log/Dispatch.pm line 74
Log::Dispatch::log('Log::Dispatch=HASH(0xfc578)','level','aler
+t','message','This is an alert') called at /usr/local/lib/perl5/site_
+perl/5.8.3/Log/Dispatch.pm line 22
Log::Dispatch::__ANON__('Log::Dispatch=HASH(0xfc578)','This is
+ an alert') called at line 7
What am I missing?
Liz
Update:
Thanks ysth for the feedback. In the end, it has come to removing the first 4 lines from Carp::longmess. The actual regexp to remove the first 4 lines will become s#^(?:[^\n]*\n){4}##s. New version of Log::Dispatch::Perl is on its way to CPAN.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Outside of code tags, you may need to use entities for some characters:
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.