Log::Sigil - show warnings with sigil prefix
filename: synopsis.pl 1 use Log::Sigil qw( swarn swarn2 ); 2 3 sub foo { 4 swarn( "foo" ); 5 swarn( "bar" ); 6 } 7 8 swarn( "foo" ); 9 10 foo( ); 11 12 swarn( "bar" ); above shows: === foo by synopsis.pl[8]: main:: +++ foo by synopsis.pl[4]: main::foo +++ bar by synopsis.pl[5]: main::foo === bar by synopsis.pl[12]: main::
This module helps printing debug by adding prefix to the warning message. The prefix will change if caller changes, meaning 'foo' sub, and 'bar' sub have different prefix each other.
i do printing debug frequently. In debugging, my warning messages became too big to read. When i in trouble (yes, so doing printing debug), i do not want to remove the warning messages. Once i thought it is needed, it is needed twice, and more. Thus, i need a format which can read warning messages even if that is big.
Works all of this module does. That are, adding prefix, setting up filename and line, and, setting up package and subroutine.
Same as swarn, but has a 1 bias. This is useful when calling from some handler subroutine, such as;
( my $ua = LWP::UserAgent->new )->add_handler( request_prepare => sub { my( $req, $ua, $h ) = @_; swarn2( "Adding If-Modified-Since..." ); $req->... swarn2( "Now req has: ", $req->header( "If-Modified-Since" ) ); }, );
swarn does not work well this case; this has deep frames.
Oops, that case needs more depth. Increase BIAS value these cases.
( my $ua = LWP::UserAgent->new )->add_handler( request_prepare => sub { my( $req, $ua, $h ) = @_; local $Log::Sigil::BIAS += 4; swarn( "Adding" ); }, ); $ua->get( "http://example.com/" ); # --> +++ Adding by .../LWP/UserAgent.pm[243]: LWP::UserAgent::prepare_request
Is a array which are used as prefix.
Specifies how many sigil is repeated.
Will be placed between sigils and log message.
Controls caller frame depth.
kuniyoshi kouji <kuniyoshi@cpan.org>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Log::Sigil, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Log::Sigil
CPAN shell
perl -MCPAN -e shell install Log::Sigil
For more information on module installation, please visit the detailed CPAN module installation guide.