Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

fixing caller_depth for %F and friends (BDUGGAN++)

  • Loading branch information...
commit b47867f1fb9eb20ce0d9dc7a4367fdcce0daf97a 1 parent 8f66fe4
Breno G. de Oliveira authored

Showing 1 changed file with 30 additions and 15 deletions. Show diff stats Hide diff stats

  1. +30 15 lib/MojoX/Log/Log4perl.pm
45 lib/MojoX/Log/Log4perl.pm
@@ -24,21 +24,33 @@ sub new {
24 24 }
25 25
26 26 # Hmm. Ah, a picture of my mommy.
27   -sub trace { shift->_get_logger->trace(@_) }
28   -sub debug { shift->_get_logger->debug(@_) }
29   -sub info { shift->_get_logger->info(@_) }
30   -sub warn { shift->_get_logger->warn(@_) }
31   -sub error { shift->_get_logger->error(@_) }
32   -sub fatal { shift->_get_logger->fatal(@_) }
33   -
34   -sub logwarn { shift->_get_logger->logwarn(@_) }
35   -sub logdie { shift->_get_logger->logdie(@_) }
36   -sub error_warn { shift->_get_logger->error_warn(@_) }
37   -sub error_die { shift->_get_logger->error_die(@_) }
38   -sub logcarp { shift->_get_logger->logcarp(@_) }
39   -sub logcluck { shift->_get_logger->logcluck(@_) }
40   -sub logcroak { shift->_get_logger->logcroak(@_) }
41   -sub logconfess { shift->_get_logger->logconfess(@_) }
  27 +{
  28 + no strict 'refs';
  29 + for my $level (
  30 + qw/ trace
  31 + debug
  32 + info
  33 + warn
  34 + error
  35 + fatal
  36 + logwarn
  37 + logdie
  38 + error_warn
  39 + error_die
  40 + logcarp
  41 + logcluck
  42 + logcroak
  43 + logconfess
  44 + / ) {
  45 +
  46 + *{ __PACKAGE__ . "::$level" } =
  47 + sub {
  48 + local $Log::Log4perl::caller_depth =
  49 + $Log::Log4perl::caller_depth + 1;
  50 + shift->_get_logger->$level(@_);
  51 + };
  52 + }
  53 +}
42 54
43 55 sub log {
44 56 my ($self, $level, @msgs) = @_;
@@ -48,6 +60,8 @@ sub log {
48 60 # Check
49 61 $level = lc $level;
50 62 if ($level =~ m/^(?:trace|debug|info|warn|error|fatal)$/o) {
  63 + local $Log::Log4perl::caller_depth =
  64 + $Log::Log4perl::caller_depth + 1;
51 65 $logger->$level(@msgs);
52 66 }
53 67
@@ -101,6 +115,7 @@ sub _get_logger {
101 115 return $logger;
102 116 }
103 117
  118 +1;
104 119 __END__
105 120 =head1 NAME
106 121

0 comments on commit b47867f

Please sign in to comment.
Something went wrong with that request. Please try again.