Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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.


In reply to How to lose Carp levels with @CARP_NOT? by liz

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (7)
As of 2024-04-25 15:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found