The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Log::Sigil - show warnings with sigil prefix

SYNOPSIS

  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::

DESCRIPTION

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.

EXPORTS

swarn
swarn2

FUNCTIONS

swarn

Works all of this module does. That are, adding prefix, setting up filename and line, and, setting up package and subroutine.

swarn2

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

PROPERTIES

SIGILS

Is a array which are used as prefix.

TIMES

Specifies how many sigil is repeated.

SEPARATOR

Will be placed between sigils and log message.

BIAS

Controls caller frame depth.

AUTHOR

kuniyoshi kouji <kuniyoshi@cpan.org>

SEE ALSO

LICENSE

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.