[Catalyst] Catalyst under Plack (PSGI)

Oleg A. Mamontov oleg at mamontov.net
Mon Feb 21 13:01:18 GMT 2011


On Feb 21, 2011, at 3:43 PM, Hernan Lopes wrote:

> to configure your logs on catalyst and psgi, create your myapp/script/my_app.psgi correctly and tell it where to log, like this

But there is some logging Plack::Middleware from box:
SimpleLogger, NullLogger, LogDispatch, Log4perl.

They seems flexible and reusable, is there any reasons
not to use it with Catalyst?


> 
> #!/usr/bin/env perl
> use strict;
> use warnings;
> use lib ( "./lib" ); 
> use MyApp;
> 
> use Catalyst::Engine::PSGI;
> use FCGI::ProcManager;
> use Plack::Builder;
> use Plack::Middleware::AccessLog;
> use Plack::Middleware::Debug;
> 
> my $name = `pwd`;
> $name =~ s/\W//g;
> my $log_dir = '/catalyst';
> die "log_dir $log_dir does not exist\n" unless -d $log_dir;
> die "log_dir $log_dir is not writable\n" unless -w $log_dir;
> 
> MyApp->setup_engine('PSGI');
> my $app = sub { MyApp->run(@_) };
> 
> builder {
>     my $logfh;
>     my $access_logfile = "$log_dir/access-log-$name";
>     my $error_logfile = "$log_dir/error-log-$name";
>     open $logfh, ">>", $access_logfile or die $!;
>     open STDERR, ">>", $error_logfile or die $!;
>     $logfh->autoflush(1);
> 
>     enable "AccessLog", logger => sub { print $logfh @_ };
> 
>     # if we're using perlbal, fix some request params. replace 12.34.56.78 with your public IP                                     
>     enable_if { $_[0]->{REMOTE_ADDR} eq '127.0.0.1'
>                     || $_[0]->{REMOTE_ADDR} eq '123.123.123.123' }
>     "Plack::Middleware::ReverseProxy";
> 
>     return $app;
> };
> 
> 
> On Mon, Feb 21, 2011 at 9:11 AM, Oleg A. Mamontov <oleg at mamontov.net> wrote:
> Hello.
> 
> I trying to switch my Catalyst application from mod_perl to Plack.
> But can't understand how to deal with stderr properly?
> Warning from catalyst goes to stderr and Plack doesn't capture it
> into psgi.errors, is it right behavour?
> 
> 
> Now i use workaround: C::P::Log::Dispatch and C::P::LogWarnings, but
> it seems to me not the right decision.
> 
> Perhaps Catalyst::Engine::PSGI may duplicate stderr with psgi.errors?
> 
> --
> Cheers,
> Oleg A. Mamontov
> 
> mailto:  oleg at mamontov.net
> 
> jabber:  lonerr at charla.mamontov.net
> icq uin: 79-521-617
> cell:    +7-903-798-1352
> 
> 
> _______________________________________________
> List: Catalyst at lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/
> 
> _______________________________________________
> List: Catalyst at lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/


-- 
Cheers,
Oleg A. Mamontov

mailto:  oleg at mamontov.net

jabber:  lonerr at charla.mamontov.net
icq uin: 79-521-617
cell:    +7-903-798-1352




More information about the Catalyst mailing list