File Coverage

blib/lib/Log/Dispatch/XML.pm
Criterion Covered Total %
statement 3 3 100.0
branch n/a
condition n/a
subroutine 1 1 100.0
pod n/a
total 4 4 100.0


line stmt bran cond sub pod time code
1             package Log::Dispatch::XML;
2 1     1   1072 use base 'Log::Dispatch::Buffer';
  1         3  
  1         995  
3              
4             # Make sure we have version info for this module
5             # Be strict from now on
6              
7             $VERSION = '0.01';
8             use strict;
9              
10             # Satisfy require
11              
12             1;
13              
14             #---------------------------------------------------------------------------
15             # xml
16             #
17             # Return the collected messages as XML. Reset buffer unless inhibited.
18             #
19             # IN: 1 instantiated object
20             # 2 name (+ optional attributes) of outer container (default: messages)
21             # 3 flag: inhibit flushing of messages
22             # OUT: 1 XML of all the collected messages
23              
24             sub xml {
25              
26             # Obtain the parameters
27             # Set the default container
28             # Set the close container
29             # Set the method to be used for fetching messages
30              
31             my ($self,$open,$method) = @_;
32             $open ||= 'messages';
33             my $close = $open =~ m#^([\w:\-]+)# ? $1 : '';
34             $method = $method ? 'fetch' : 'flush';
35              
36             # Obtain the messages
37             # Initialize the XML
38             # For all of the messages
39             # Add the message to the XML
40             # Return final XML
41              
42             my $messages = $self->$method;
43             my $xml = "<$open>";
44             foreach (@{$messages}) {
45             $xml .= "<$_->{'level'}>{'message'}]]>{'level'}>";
46             }
47             $xml."";
48             } #xml
49              
50             #---------------------------------------------------------------------------
51              
52             __END__