[dancer-users] Capture or redirect STDOUT

David Golden xdg at xdg.me
Wed Feb 13 21:40:25 GMT 2013


Are you running this with the default server?  IIRC, it has issues
with the standard handles.

Try with Starman:

  $ plackup --server Starman myapp.pl

On Wed, Feb 13, 2013 at 11:59 AM,  <igor.bujna at post.cz> wrote:
> Hi,
> i want to capture STDOUT under my Dancer applications with package
> Capture::Tiny. I have this simple Perl test:
>
> --------------------------------------------------------------------------------------------------------
> use Capture::Tiny;
> my ($stdout, $stderr, $exit) = Capture::Tiny::capture {
>         system( "echo 'OK'");
> };
> print STDERR "Captured:$stdout\n";
> --------------------------------------------------------------------------------------------------------
>
> Capturing STDOUT in this script is ok, but when i move to Dancer app, that
> this faill. System print command to STDERR and nothing is captured.
>
> --------------------------------------------------------------------------------------------------------
> package Test;
> use Dancer ':syntax';
> use Capture::Tiny;
>
> our $VERSION = '0.1';
>
> get '/' => sub {
>    my ($stdout, $stderr, $exit) = Capture::Tiny::capture {
>         system( "echo 'OK'");
>    };
>    print STDERR "Captired:$stdout\n";
>     template 'index';
> };
> true;
> --------------------------------------------------------------------------------------------------------
>
> Why or where system/fork redirect STDOUT to STDERR ? How can I capture this
> under dancer. Maybe it will be possible to change system() call to own
> function, where can use IPC::Open3, but how can i made it?
>
> Thank you for yours suggestion Igor
>
>
>
> _______________________________________________
> dancer-users mailing list
> dancer-users at dancer.pm
> http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
>



-- 
David Golden <xdg at xdg.me>
Take back your inbox! → http://www.bunchmail.com/
Twitter/IRC: @xdg


More information about the dancer-users mailing list