this brings up an interesting difference in side-effects of Catalyst::Log->error() and Log::Log4perl->error().

in the course of trying to integrate catalyst logging with other existing Log4Perl loggers in the codebase, i had tried first setting catalyst's logger to be the global logger,

  $c->log($one_true_logger);

but ran into issues like those you are trying to solve.

so i tried an alternate approach,

  $one_true_logger = $c->log;

but i have existing code that relies on the side-effect of $log4perl_logger->error() [and friends] returning undef,

  return $one_true_logger->error('oops');    # logs and returns false

but Catalyst::Log::_log ends with (and thus returns)

    $self->{body} .= sprintf( "[%s] %s", $level, $message );

is there any reason not to patch Catalyst::Log::_log to 'return;' after appending $self->{body}?

(or perhaps better in the method generation,

        *{$name} = sub {
            my $self = shift;

            if ( $self->{level} & $level ) {
                $self->_log( $name, @_ );
            }
+           return;
        };

so the false RV is reliable even if level is too low.



On Mar 2, 2007, at 11:26 AM, Adam Jacob wrote:

Several people have pointed out that various parts of Log::Log4perl don't work well with Catalyst. Specifically, many of the options that rely on Stack information are incorrect. The format strings:

%L Line number within the file where the log statement was issued
%F File where the logging event occurred
%C Fully qualified package (or class) name of the caller
%M Method or function where the logging request was issued
%l Fully qualified name of the calling method followed by the callers source the file name and line number between parentheses.

Sebastian Willert has helpfully provided a patch that should resolve these issues. He rules. His changes have been put on this branch:

http://dev.catalyst.perl.org/repos/Catalyst/branches/Catalyst-Log- Log4perl/cspec-fixes

I'm going to be pretty busy for the next few days, but don't want to sit on this any longer. Can those of you using Catalyst::Log::Log4perl give this a whirl, and make sure it works with your applications? (And doesn't cause any kind of nasty performance implications, especially with the cspec fixes disabled?)

Your rewards will be my enduring gratitude, and a better Catalyst::Log::Log4perl.

Thanks!

Adam

_______________________________________________
List: [email protected]
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/ [email protected]/
Dev site: http://dev.catalyst.perl.org/



_______________________________________________
List: [email protected]
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/

Reply via email to