Skip to content

Commit

Permalink
Added documentation on how to use Log4perl's :easy macros
Browse files Browse the repository at this point in the history
with Catalyst in Log::Log4perl::Catalyst.
  • Loading branch information
mschilli committed Mar 20, 2010
1 parent d109f57 commit aeaf10c
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
##################################################

1.29 (not yet released)
* (ms) Added documentation on how to use Log4perl's :easy macros
with Catalyst in Log::Log4perl::Catalyst.

1.28 (2010/02/24)
* (ms) Fixed caller stack with Buffer composite appender
Expand Down
34 changes: 34 additions & 0 deletions lib/Log/Log4perl/Catalyst.pm
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,40 @@ Clears the logging system's internal buffers without logging anything.
=back
=head2 Using :easy Macros with Catalyst
If you're tired of typing
$c->log->debug("...");
and would prefer to use Log4perl's convenient :easy mode macros like
DEBUG "...";
then just pull those macros in via Log::Log4perl's :easy mode and start
cranking:
use Log::Log4perl qw(:easy);
# ... use macros later on
sub base :Chained('/') :PathPart('apples') :CaptureArgs(0) {
my ( $self, $c ) = @_;
DEBUG "Handling apples";
}
Note the difference between Log4perl's initialization in Catalyst, which
uses the Catalyst-specific Log::Log4perl::Catalyst module (top of this
page), and making use of Log4perl's loggers with the standard
Log::Log4perl loggers and macros. While initialization requires Log4perl
to perform dark magic to conform to Catalyst's different logging strategy,
obtaining Log4perl's logger objects or calling its macros are unchanged.
Instead of using Catalyst's way of referencing the "context" object $c to
obtain logger references via its log() method, you can just as well use
Log4perl's get_logger() or macros to access Log4perl's logger singletons.
The result is the same.
=head1 COPYRIGHT AND LICENSE
Copyright 2002-2010 by Mike Schilli E<lt>m@perlmeister.comE<gt>
Expand Down

0 comments on commit aeaf10c

Please sign in to comment.