summary refs log tree commit diff
path: root/lib/Dancer/Logger
diff options
context:
space:
mode:
authorfranck cuny <franck@lumberjaph.net>2010-04-17 13:23:08 +0200
committerfranck cuny <franck@lumberjaph.net>2010-04-17 13:23:08 +0200
commit2d615db13d2dbe9f134d8cc59f0b770282bf35b6 (patch)
tree9ee716dc599f12896150d1d38978f99b3724ba00 /lib/Dancer/Logger
parentinitial commit (diff)
downloaddancer-logger-psgi-2d615db13d2dbe9f134d8cc59f0b770282bf35b6.tar.gz
log to psgix.logger
Diffstat (limited to 'lib/Dancer/Logger')
-rw-r--r--lib/Dancer/Logger/PSGI.pm34
1 files changed, 31 insertions, 3 deletions
diff --git a/lib/Dancer/Logger/PSGI.pm b/lib/Dancer/Logger/PSGI.pm
index f6e6dd4..797def4 100644
--- a/lib/Dancer/Logger/PSGI.pm
+++ b/lib/Dancer/Logger/PSGI.pm
@@ -4,20 +4,46 @@ use strict;
 use warnings;
 our $VERSION = '0.01';
 
+use Dancer::SharedData;
+use base 'Dancer::Logger::Abstract';
+
+sub init {}
+
+sub _log {
+    my ( $self, $level, $message ) = @_;
+    my $request = Dancer::SharedData->request;
+    if ( $request->{env}->{'psgix.logger'} ) {
+        $request->{env}->{'psgix.logger'}
+            ->( { level => $level, message => $message } );
+    }
+}
+
 1;
 __END__
 
 =head1 NAME
 
-Dancer::Logger::PSGI -
+Dancer::Logger::PSGI - PSGI logger handler for Dancer
 
 =head1 SYNOPSIS
 
-  use Dancer::Logger::PSGI;
+In your Dancer's configuration file:
+
+    logger: PSGI
+
+In your application
+
+    warning "this is a warning"
+
+In your app.psgi
+
+    $app = builder { enable "ConsoleLogger"; $app; }
+
+With L<Plack::Middleware::ConsoleLogger>, all your log will be send to the javascript console of your browser.
 
 =head1 DESCRIPTION
 
-Dancer::Logger::PSGI is
+This class is an interface between your Dancer's application and B<psgix.logger>. Message will be logged in whatever logger you decided to use in your L<Plack> handler. If no logger is defined, nothing will be logged.
 
 =head1 AUTHOR
 
@@ -25,6 +51,8 @@ franck cuny E<lt>franck@lumberjaph.netE<gt>
 
 =head1 SEE ALSO
 
+L<Plack::Middleware::ConsoleLogger>, L<Plack::Middleware::NullLogger>, L<Plack::Middleware::Log4perl>.
+
 =head1 LICENSE
 
 This library is free software; you can redistribute it and/or modify