Log-LogMethods

 view release on metacpan or  search on metacpan

lib/Log/LogMethods.pm  view on Meta::CPAN

package Log::LogMethods;

use Modern::Perl;
use Time::HiRes qw(tv_interval gettimeofday);
use Ref::Util qw(is_plain_hashref is_blessed_hashref);
use Scalar::Util qw(blessed);
use B qw(svref_2object);
use Scalar::Util qw(looks_like_number);
no warnings 'redefine';
use Log::Log4perl;
use Log::Log4perl::Level;
Log::Log4perl->wrapper_register(__PACKAGE__);
use Moo::Role;

use Carp qw(croak);
use namespace::clean;

our $VERSION='1.010';
our $SKIP_TRIGGER=0;

# used as a place holder for extended format data
our $CURRENT_CB;
BEGIN { 

  # disable logging
  #local $SIG{__WARN__}=sub { };

  # always should be before off
  Log::Log4perl::Logger::create_custom_level(qw( ALWAYS OFF)); 
}

sub LOOK_BACK_DEPTH { 3; }

our %LEVEL_MAP=(
  OFF=>$OFF,
  ALWAYS=>$ALWAYS,
  FATAL=>$FATAL,
  ERROR=>$ERROR,
  WARN=>$WARN,
  INFO=>$INFO,
  DEBUG=>$DEBUG,
  TRACE=>$TRACE,
);

=pod

=head1 NAME

Log::LogMethods - Writes your logging code for you!

=head1 SYNOPSIS

  package test_moo;

  use Moo;
  BEGIN { with qw(Log::LogMethods) }
  sub test_always : BENCHMARK_ALWAYS { ...  }

  my $logger=Log::Log4perl->get_logger(__PACKAGE__);
  my $class=new test_moo(logger=>$logger);

=cut



( run in 1.135 second using v1.01-cache-2.11-cpan-39bf76dae61 )