[Xml-compile] Logging from callback

Robin V. robinsp at gmail.com
Thu Apr 22 23:20:10 GMT 2010


On Thu, Apr 22, 2010 at 9:25 AM, Mark Overmeer <mark at overmeer.net> wrote:
> * Robin V. (robinsp at gmail.com) [100421 22:40]:
>> I'm fighting (again) with logging framework of xml::compile. The
>> complexity of the Log::Report taking over other logging mechanisms is
>> driving me crazy and after an hour of tries I think I need somebody
>> help.
>
> Complex?  The use of Log::Report is rather simple. The problem is
> that you mix two logging frameworks within one program.

In fact, I'm not a perl guru and the capture of stdin/stdout, the
default redirection to windows event service (when I was working with
strawberry perl)... it's enough to confuse me. I didn't want to mix
frameworks, but as I started to use log4perl in my project, I didn't
expect to have to change logging tool because of a module I use.

>> Moose classes rely on log4perl in simple mode (
>> Log::Log4perl->easy_init( $DEBUG ); ) and everything is fine (I can
>> log from my object constructor). But if I try to log using
>> ERROR("XXX") or DEBUG("XXX") from the callback, I can see nothing. I
>> also tried simple print without any more results. I tried different
>> things like, dispatcher PERL => 'usual',  mode => 'DEBUG'; without
>> success.
>
> With Log::Report, you have exception generators, like error() and
> exception handlers: dispatchers.  You can dispatch to Log::Log4perl.

In fact, I didn't really need log4perl. I could have used Log::Report
from the beginning so the dispatcher doesn't really matter to me. I'm
more concerned with the changing of logging API among different files
of my project :).

I tried to only use log::report in this module of my program, and I
finally managed to log with the syslog backend:
dispatcher SYSLOG => 'syslog', accept => 'INFO-';
[...]
	sub my_callback()
	{
		my ($soap, $data_in) = @_;
		notice("Msg ID:
".$data_in->{CheckStatus}->{Request}->{MessageIdentifier}."\n");

For some unknown reason, I didn't managed to see anything from the
'PERL' backend where logs outside the callback were working, but not
the logs from the callback itself. With the 'FILE' backend, I managed
to write logs, but the file writing was buffered until closing which
was useless for debugging puropse.

I'll continue with Log::Report and 'SYSLOG' backend. If you think
there was something wrong, some possible bug, I can do some tries for
you.

>  use Log::Report;
>
>  dispatcher Log::Log4perl => 'l4p', accept => 'NOTICE-'
>    , config => "$ENV{HOME}/.log.conf";
>
> See Log::Report::Dispatcher::Log4perl
> The module does call    Log::Log4perl->init($config);
> which may be inconvenient because probably Moose will do that as well.
> So if you have suggestions for interface extension, then feel invited.

I didn't try log4perl backend as I was mainly focused on the API, not
the configuration. So I didn't have problems with init... yet :).

Thanks for your answer.

Regards,
Robin



More information about the Xml-compile mailing list