diff --git a/lib/Dancer2/Core/Role/Logger.pm b/lib/Dancer2/Core/Role/Logger.pm index 3b49a828d..b260f42ab 100644 --- a/lib/Dancer2/Core/Role/Logger.pm +++ b/lib/Dancer2/Core/Role/Logger.pm @@ -242,6 +242,10 @@ The possible values are: =over 4 +=item %a + +app name + =item %h host emitting the request diff --git a/lib/Dancer2/Manual.pod b/lib/Dancer2/Manual.pod index 42b095251..30f0b4f46 100644 --- a/lib/Dancer2/Manual.pod +++ b/lib/Dancer2/Manual.pod @@ -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 or L: + + 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 diff --git a/t/logger.t b/t/logger.t index e45a5949d..4cc5b9e3a 100644 --- a/t/logger.t +++ b/t/logger.t @@ -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 )