Log::Dispatch::XML - Collect one or more messages in XML format
use Log::Dispatch::XML (); my $dispatcher = Log::Dispatch->new; my $channel = Log::Dispatch::XML->new( name => 'foo', min_level => 'info', ) ); $dispatcher->add( $channel ); $dispatcher->warning( "This is a warning" ); my $xml = $channel->xml; # <messages><warning><![CDATA[This is a warning]]></warning></messages>
The "Log::Dispatch::XML" module offers a buffering logging alternative for XML users. Messages are collected in the output channel until XML is created from them.
Apart from the methods provided by Log::Dispatch::Buffer (and implicitely from Log::Dispatch::Output), the following method is available:
$xml = $channel->xml; $xml = $channel->xml( qq{log:messages xmlns:log="http://foo.com"} );
Return the XML of the messages collected on that channel. Two optional input parameters can be provided:
The name + attributes of the outer container that should be used to generate the XML. By default, "messages" will be assumed.
By default, once XML is generated from the messages, the messages are flushed from the output channel. Specifying a true value causes the messages not to be flushed.
The XML format that is generated is very simple. The name and the attributes of the outer container is (implicitely) specified with the call to "xml". Inside this container, there is one container for each message: the name of that container is the same as the level of the message. The content of the container, is the text of the message. To ensure well-formedness of XML, the message is put inside a CDATA section.
Log::Dispatch (1.16) Log::Dispatch::Buffer (any)
Elizabeth Mattijsen, <liz@dijkmat.nl>.
Please report bugs to <perlbugs@dijkmat.nl>.
Copyright (c) 2004 Elizabeth Mattijsen <liz@dijkmat.nl>. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Log::Dispatch::XML, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Log::Dispatch::XML
CPAN shell
perl -MCPAN -e shell install Log::Dispatch::XML
For more information on module installation, please visit the detailed CPAN module installation guide.