Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

  • Loading branch information...
commit b47867f1fb9eb20ce0d9dc7a4367fdcce0daf97a 1 parent 8f66fe4
Breno G. de Oliveira authored
Showing with 30 additions and 15 deletions.
  1. +30 −15 lib/MojoX/Log/Log4perl.pm
45 lib/MojoX/Log/Log4perl.pm
View
@@ -24,21 +24,33 @@ sub new {
}
# Hmm. Ah, a picture of my mommy.
-sub trace { shift->_get_logger->trace(@_) }
-sub debug { shift->_get_logger->debug(@_) }
-sub info { shift->_get_logger->info(@_) }
-sub warn { shift->_get_logger->warn(@_) }
-sub error { shift->_get_logger->error(@_) }
-sub fatal { shift->_get_logger->fatal(@_) }
-
-sub logwarn { shift->_get_logger->logwarn(@_) }
-sub logdie { shift->_get_logger->logdie(@_) }
-sub error_warn { shift->_get_logger->error_warn(@_) }
-sub error_die { shift->_get_logger->error_die(@_) }
-sub logcarp { shift->_get_logger->logcarp(@_) }
-sub logcluck { shift->_get_logger->logcluck(@_) }
-sub logcroak { shift->_get_logger->logcroak(@_) }
-sub logconfess { shift->_get_logger->logconfess(@_) }
+{
+ no strict 'refs';
+ for my $level (
+ qw/ trace
+ debug
+ info
+ warn
+ error
+ fatal
+ logwarn
+ logdie
+ error_warn
+ error_die
+ logcarp
+ logcluck
+ logcroak
+ logconfess
+ / ) {
+
+ *{ __PACKAGE__ . "::$level" } =
+ sub {
+ local $Log::Log4perl::caller_depth =
+ $Log::Log4perl::caller_depth + 1;
+ shift->_get_logger->$level(@_);
+ };
+ }
+}
sub log {
my ($self, $level, @msgs) = @_;
@@ -48,6 +60,8 @@ sub log {
# Check
$level = lc $level;
if ($level =~ m/^(?:trace|debug|info|warn|error|fatal)$/o) {
+ local $Log::Log4perl::caller_depth =
+ $Log::Log4perl::caller_depth + 1;
$logger->$level(@msgs);
}
@@ -101,6 +115,7 @@ sub _get_logger {
return $logger;
}
+1;
__END__
=head1 NAME
Please sign in to comment.
Something went wrong with that request. Please try again.