How to redirect stderr to C lang function

L

Lukas Petrlik

I was considering the following possibilities:

1) To include logging in the Perl's internal function
util.c:perl_write_to_stderr().

This possibility is quite simple, but I would have to modify Perl
sources.

2) To use binmode (STDERR, ":via(myModule)") and call back the logging
function; the disadvantage of this solution is that it would not log most
syntactic errors.

3) To call PerlIO_stdstreams() and assign to PL_perlio[3], before we call
perl_parse().

This third solution is probably the best one, but I will have to fill my
own PerlIO structure and ensure that it will get free()d once and only
once.

Is there a better possibility?

Lukas
 
M

Matija Papec

X-Ftn-To: Lukas Petrlik

Lukas Petrlik said:
3) To call PerlIO_stdstreams() and assign to PL_perlio[3], before we call
perl_parse().

This third solution is probably the best one, but I will have to fill my
own PerlIO structure and ensure that it will get free()d once and only
once.

Is there a better possibility?

You can tie STDERR to your custom class which will capture all STDERR
output. There are also some modules that can do such things for you,
http://search.cpan.org/search?query=stderr&mode=all
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top