File Coverage

blib/lib/XAS/Logmon/Parser/XAS/Logs.pm
Criterion Covered Total %
statement 6 28 21.4
branch 0 2 0.0
condition n/a
subroutine 2 4 50.0
pod 2 2 100.0
total 10 36 27.7


line stmt bran cond sub pod time code
1             package XAS::Logmon::Parser::XAS::Logs;
2              
3             our $VERSION = '0.01';
4              
5 1     1   328 use XAS::Lib::Regexp::Log::XAS;
  1         1  
  1         35  
6              
7             use XAS::Class
8 1         8 debug => 0,
9             version => $VERSION,
10             base => 'XAS::Base',
11             utils => 'trim dotid db2dt',
12             accessors => 'regex fields',
13 1     1   4 ;
  1         1  
14              
15             #use Data::Dumper;
16              
17             # ----------------------------------------------------------------------
18             # Public Methods
19             # ----------------------------------------------------------------------
20              
21             sub parse {
22 0     0 1   my $self = shift;
23 0           my $line = shift;
24              
25 0           my %data;
26 0           my $regex = $self->regex;
27 0           my $fields = $self->fields;
28              
29 0 0         if ((@data{@$fields}) = ($line =~ /$regex/)) {
30              
31 0           $data{'datetime'} = db2dt($data{'datetime'});
32 0           $data{'message'} = trim($data{'message'});
33 0           $data{'type'} = 'xas-logs';
34              
35 0           return \%data;
36              
37             }
38              
39 0           return undef;
40              
41             }
42              
43             # ----------------------------------------------------------------------
44             # Private Methods
45             # ----------------------------------------------------------------------
46              
47             sub init {
48 0     0 1   my $self = shift;
49 0           my $config = shift;
50              
51 0           my @args;
52              
53 0           while (my ($key, $value) = each(%$config)) {
54              
55 0           push(@args, $key);
56 0           push(@args, $value);
57              
58             }
59              
60 0           my $reg = XAS::Lib::Regexp::Log::XAS->new(@args);
61 0           my @fields = $reg->capture;
62              
63 0           $self->{'regex'} = $reg->regexp;
64 0           $self->{'fields'} = \@fields;
65              
66 0           return $self;
67              
68             }
69              
70             1;
71              
72             __END__