line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Log::Shiras::Report; |
2
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:JANDREW'; |
3
|
1
|
|
|
1
|
|
810720
|
use version; our $VERSION = version->declare("v0.48.0"); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
6
|
|
4
|
1
|
|
|
1
|
|
70
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
15
|
|
5
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
17
|
|
6
|
1
|
|
|
1
|
|
14
|
use 5.010; |
|
1
|
|
|
|
|
2
|
|
7
|
1
|
|
|
1
|
|
3
|
use utf8; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
8
|
|
|
|
|
|
|
#~ use lib '../../'; |
9
|
|
|
|
|
|
|
#~ use Log::Shiras::Unhide qw( :InternalReporT ); |
10
|
|
|
|
|
|
|
###InternalReporT warn "You uncovered internal logging statements for Log::Shiras::Report-$VERSION" if !$ENV{hide_warn}; |
11
|
|
|
|
|
|
|
###InternalReporT use Log::Shiras::Switchboard; |
12
|
|
|
|
|
|
|
###InternalReporT my $switchboard = Log::Shiras::Switchboard->instance; |
13
|
1
|
|
|
1
|
|
24
|
use Carp qw( confess cluck ); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
55
|
|
14
|
1
|
|
|
1
|
|
4
|
use MooseX::Types::Moose qw( ArrayRef HashRef ); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
6
|
|
15
|
1
|
|
|
1
|
|
3121
|
use Moose::Role; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
16
|
|
|
|
|
|
|
requires 'add_line'; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
#########1 Public Attributes 3#########4#########5#########6#########7#########8#########9 |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
#########1 Public Methods 3#########4#########5#########6#########7#########8#########9 |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
#########1 Private Attributes 3#########4#########5#########6#########7#########8#########9 |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
#########1 Private Methods 3#########4#########5#########6#########7#########8#########9 |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
around add_line => sub{ |
33
|
|
|
|
|
|
|
my( $_add_line, $self, $message_ref ) = @_; |
34
|
|
|
|
|
|
|
###InternalReporT $switchboard->master_talk( { report => 'log_file', level => 1, |
35
|
|
|
|
|
|
|
###InternalReporT name_space => 'Log::Shiras::Report::add_line', |
36
|
|
|
|
|
|
|
###InternalReporT message =>[ 'Scrubbing the message ref:', $message_ref ], } ); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# Scrub the input |
39
|
|
|
|
|
|
|
if( !is_HashRef( $message_ref ) ){ |
40
|
|
|
|
|
|
|
confess "Expected the message to be passed as a hashref"; |
41
|
|
|
|
|
|
|
}elsif( !exists $message_ref->{message} ){ |
42
|
|
|
|
|
|
|
cluck "Passing an empty message to the report"; |
43
|
|
|
|
|
|
|
$message_ref->{message} = []; |
44
|
|
|
|
|
|
|
###InternalReporT $switchboard->master_talk( { report => 'log_file', level => 3, |
45
|
|
|
|
|
|
|
###InternalReporT name_space => 'Log::Shiras::Report::CSVFile::add_line', |
46
|
|
|
|
|
|
|
###InternalReporT message =>[ 'Message ref has no message:', $message_ref ], } ); |
47
|
|
|
|
|
|
|
}elsif( !is_ArrayRef( $message_ref->{message} ) ){ |
48
|
|
|
|
|
|
|
confess "The passed 'message' key value is not an array ref"; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
# Check for a manage_message add on |
52
|
|
|
|
|
|
|
if( $self->can( 'manage_message' ) ){ |
53
|
|
|
|
|
|
|
$message_ref = $self->manage_message( $message_ref ); |
54
|
|
|
|
|
|
|
###InternalReporT $switchboard->master_talk( { report => 'log_file', level => 1, |
55
|
|
|
|
|
|
|
###InternalReporT name_space => 'Log::Shiras::Report::CSVFile::add_line', |
56
|
|
|
|
|
|
|
###InternalReporT message =>[ 'Updated the message to:', $message_ref->{message} ], } ); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# Implement the method |
60
|
|
|
|
|
|
|
my $times = $self->$_add_line( $message_ref ); |
61
|
|
|
|
|
|
|
###InternalReporT $switchboard->master_talk( { report => 'log_file', level => 2, |
62
|
|
|
|
|
|
|
###InternalReporT name_space => 'Log::Shiras::Report::add_line', |
63
|
|
|
|
|
|
|
###InternalReporT message =>[ 'add_line wrap finished', $times, $message_ref ], } ); |
64
|
|
|
|
|
|
|
return $times; |
65
|
|
|
|
|
|
|
}; |
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
0
|
|
|
sub _my_test_for_around_add_line{ 1 }; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
#########1 Phinish 3#########4#########5#########6#########7#########8#########9 |
71
|
|
|
|
|
|
|
|
72
|
1
|
|
|
1
|
|
3233
|
no Moose::Role; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
5
|
|
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
1; |
75
|
|
|
|
|
|
|
# The preceding line will help the module return a true value |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
#########1 main pod docs 3#########4#########5#########6#########7#########8#########9 |
78
|
|
|
|
|
|
|
__END__ |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 NAME |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Log::Shiras::Report - Report Role (Interface) for Log::Shiras |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 SYNOPSIS |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
use Modern::Perl; |
87
|
|
|
|
|
|
|
use Log::Shiras::Switchboard; |
88
|
|
|
|
|
|
|
use Log::Shiras::Report; |
89
|
|
|
|
|
|
|
use Log::Shiras::Report::CSVFile; |
90
|
|
|
|
|
|
|
my $operator = Log::Shiras::Switchboard->get_operator( |
91
|
|
|
|
|
|
|
name_space_bounds =>{ |
92
|
|
|
|
|
|
|
UNBLOCK =>{ |
93
|
|
|
|
|
|
|
to_file => 'info',# for info and more urgent messages |
94
|
|
|
|
|
|
|
}, |
95
|
|
|
|
|
|
|
}, |
96
|
|
|
|
|
|
|
reports =>{ |
97
|
|
|
|
|
|
|
to_file =>[{ |
98
|
|
|
|
|
|
|
superclasses =>[ 'Log::Shiras::Report::CSVFile' ], |
99
|
|
|
|
|
|
|
add_roles_in_sequence =>[ |
100
|
|
|
|
|
|
|
'Log::Shiras::Report', |
101
|
|
|
|
|
|
|
'Log::Shiras::Report::MetaMessage', |
102
|
|
|
|
|
|
|
],# Effectivly an early class type check |
103
|
|
|
|
|
|
|
file => 'test.csv', |
104
|
|
|
|
|
|
|
}], |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
); |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 DESCRIPTION |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
This is a simple interface that ensures the report object has an 'add_line' method. It also |
111
|
|
|
|
|
|
|
scrubs the input to 'add_line' method to ensure the message is a hashref with the key message. |
112
|
|
|
|
|
|
|
Finally, it calls a method 'manage_message' if it has been composed into the larger class. |
113
|
|
|
|
|
|
|
For an example see L<Log::Shiras::Report::MetaMessage>. If you wish to build your own report |
114
|
|
|
|
|
|
|
object it just has to have an add_line method. To use the report it is registered to the |
115
|
|
|
|
|
|
|
switchboard using L<Log::Shiras::Switchboard/reports> For an example of a simple report see |
116
|
|
|
|
|
|
|
L<Log::Shiras::Report::Stdout> For an example of a complex report see |
117
|
|
|
|
|
|
|
L<Log::Shiras::Report::CSVFile> Upon registration the reports will receive their messages from |
118
|
|
|
|
|
|
|
L<Log::Shiras::Switchboard/master_talk( $args_ref )>. |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 SUPPORT |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=over |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
L<Log-Shiras/issues|https://github.com/jandrew/Log-Shiras/issues> |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=back |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head1 TODO |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=over |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
B<1.> Nothing L<currently|/SUPPORT> |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=back |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head1 AUTHOR |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=over |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=item Jed Lund |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=item jandrew@cpan.org |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=back |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head1 COPYRIGHT |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
This program is free software; you can redistribute |
149
|
|
|
|
|
|
|
it and/or modify it under the same terms as Perl itself. |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
The full text of the license can be found in the |
152
|
|
|
|
|
|
|
LICENSE file included with this module. |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=over |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
L<version> |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
L<Moose::Role> - requires (add_line) |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
L<MooseX::Types::Moose> |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
L<Carp> - confess cluck |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=back |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=cut |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
#########1#########2 main pod documentation end 5#########6#########7#########8#########9 |