ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bernard Davison" <bdavi...@towertechnology.com.au>
Subject Re: Proposal: XML output from ant tasks
Date Fri, 25 Feb 2000 05:22:17 GMT


from the way this thread is going it seems as thought this is a difficult task.
I don't really think it is. call me naive if you like but its really is easy.

the problem as i see it is the way in which we log messages.
I have implemented a log module in perl that if implemented in Java would solve
many of the issues that are being presented here.
hope some of you know your way around OO perl.

I am only just starting to learn Java and so have not implemented this Log
module in Java yet.
forgive me if my terminology is not "Java" I come from a perl background.

OK the structure of the module is like so

Log.pm
Log::Dispatch.pm
Log::Writer.pm
Log::Writer::File.pm

The Log.pm module uses Log::Dispatch.pm
The Log::Writer::File.pm uses Log::Writer.pm and Log::Dispatch.pm

what happens internally is
you create a $log_file object which registers itself with the Dispatch object.
like so

use Log::Writer::File;
my $log_file1 = new Log::Writer::File( {'file' => '/tmp/logfile.log'} );
my $log_file2 = new Log::Writer::File( {'file' => '/home/bernardd/logfile.log'}
);

you then create a log object like so (you create these in every class or module
you create)

use Log;
my $log = new Log('script_name');
$log->event("started");
$log->error("1","error level one message");
$log->error("6","error level six message");

what happens is that each time you create a new logfile object it registers
itself with the dispatcher.
when you write the $log object it forwards the message to the dispatcher to pass
to all the Log::Writers it has registered.

$log->info("some message");

passes the log message to dispatcher which says

foreach my $logfile (@registered_log_files)
{
     $logfile->write("$message");
}

if I wanted to write the logs in XML then all I need to do is create a
Log::Writer::XML.pm module and then create a new log_file object in the program
some where.
use Log::Writer::XML;
my $log_file3 = new Log::Writer::XML( { 'file' => "/tmp/xml_log_file.log" } );

It would also be worth writing a Log::Writer::STDOUT and Log::Writer::STDERR
Could also implement Log::Reader... should get the writer working first though.

anyway have a look at the perl modules and see if you can work it out from what
I have said above.
sorry if you cannot understand what I've said above. I can explain it better on
paper. ho humm.

see ya
bernie.


(See attached file: Log.pm)(See attached file: Writer.pm)(See attached file:
Dispatch.pm)(See attached file: File.pm)





Mime
View raw message