Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document missing logging hooks and format option; fix typo #1706

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/Dancer2/Core/Role/Logger.pm
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,10 @@ The possible values are:

=over 4

=item %a

app name

=item %h

host emitting the request
Expand Down
29 changes: 29 additions & 0 deletions lib/Dancer2/Manual.pod
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,35 @@ for details on the following hooks:

=back

=head2 Logging

Logging hooks do not allow you to alter log message content, but they do
give you a place to perform extra actions. For example, if you want to send
an email for error messages, but you don't want to use a heavier logger
such as L<Log::Any> or L<Log::Log4perl>:

hook 'engine.logger.after' => sub {
my ( $logger, $level, $message ) = @_;

if( $level eq 'error' ) {
# Send an email with the message content
}
};

There are two hooks available for logging:

=over 4

=item * engine.logger.before

This hook is called before a log message is produced.

=item * engine.logger.after

This hook is called after a log message is produced.

=back

=head2 Serializers

=over 4
Expand Down
2 changes: 1 addition & 1 deletion t/logger.t
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ subtest 'log level and capture' => sub {
is_deeply $trap->read, [];
};

subtest 'logger enging hooks' => sub {
subtest 'logger engine hooks' => sub {
# before hook can change log level or message.
hook 'engine.logger.before' => sub {
my $logger = shift; # @_ = ( $level, @message_args )
Expand Down
Loading