| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Log::FreeSWITCH::Line::Data; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Pragmas. |
|
4
|
15
|
|
|
15
|
|
49621
|
use strict; |
|
|
15
|
|
|
|
|
27
|
|
|
|
15
|
|
|
|
|
384
|
|
|
5
|
15
|
|
|
15
|
|
75
|
use warnings; |
|
|
15
|
|
|
|
|
24
|
|
|
|
15
|
|
|
|
|
362
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# Modules. |
|
8
|
15
|
|
|
15
|
|
8000
|
use English; |
|
|
15
|
|
|
|
|
43526
|
|
|
|
15
|
|
|
|
|
77
|
|
|
9
|
15
|
|
|
15
|
|
19417
|
use Error::Pure::Always; |
|
|
15
|
|
|
|
|
85487
|
|
|
|
15
|
|
|
|
|
463
|
|
|
10
|
15
|
|
|
15
|
|
90
|
use Error::Pure qw(err); |
|
|
15
|
|
|
|
|
26
|
|
|
|
15
|
|
|
|
|
672
|
|
|
11
|
15
|
|
|
15
|
|
10410
|
use Mo qw(builder is required); |
|
|
15
|
|
|
|
|
7577
|
|
|
|
15
|
|
|
|
|
83
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# Version. |
|
14
|
|
|
|
|
|
|
our $VERSION = 0.06; |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
has date => ( |
|
17
|
|
|
|
|
|
|
'is' => 'ro', |
|
18
|
|
|
|
|
|
|
'required' => 1, |
|
19
|
|
|
|
|
|
|
); |
|
20
|
|
|
|
|
|
|
has datetime_obj => ( |
|
21
|
|
|
|
|
|
|
'is' => 'ro', |
|
22
|
|
|
|
|
|
|
'builder' => '_datetime', |
|
23
|
|
|
|
|
|
|
); |
|
24
|
|
|
|
|
|
|
has file => ( |
|
25
|
|
|
|
|
|
|
'is' => 'ro', |
|
26
|
|
|
|
|
|
|
'required' => 1, |
|
27
|
|
|
|
|
|
|
); |
|
28
|
|
|
|
|
|
|
has file_line => ( |
|
29
|
|
|
|
|
|
|
'is' => 'ro', |
|
30
|
|
|
|
|
|
|
'required' => 1, |
|
31
|
|
|
|
|
|
|
); |
|
32
|
|
|
|
|
|
|
has message => ( |
|
33
|
|
|
|
|
|
|
'is' => 'ro', |
|
34
|
|
|
|
|
|
|
); |
|
35
|
|
|
|
|
|
|
has raw => ( |
|
36
|
|
|
|
|
|
|
'is' => 'rw', |
|
37
|
|
|
|
|
|
|
); |
|
38
|
|
|
|
|
|
|
has time => ( |
|
39
|
|
|
|
|
|
|
'is' => 'ro', |
|
40
|
|
|
|
|
|
|
'required' => 1, |
|
41
|
|
|
|
|
|
|
); |
|
42
|
|
|
|
|
|
|
has type => ( |
|
43
|
|
|
|
|
|
|
'is' => 'ro', |
|
44
|
|
|
|
|
|
|
'required' => 1, |
|
45
|
|
|
|
|
|
|
); |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# Create DateTime object. |
|
48
|
|
|
|
|
|
|
sub _datetime { |
|
49
|
2
|
|
|
2
|
|
892
|
my $self = shift; |
|
50
|
2
|
|
|
|
|
5
|
eval { |
|
51
|
2
|
|
|
|
|
1532
|
require DateTime; |
|
52
|
|
|
|
|
|
|
}; |
|
53
|
2
|
50
|
|
|
|
144750
|
if ($EVAL_ERROR) { |
|
54
|
0
|
|
|
|
|
0
|
err "Cannot load 'DateTime' class.", |
|
55
|
|
|
|
|
|
|
'Error', $EVAL_ERROR; |
|
56
|
|
|
|
|
|
|
} |
|
57
|
2
|
|
|
|
|
11
|
my ($year, $month, $day) = split m/-/ms, $self->date; |
|
58
|
2
|
|
|
|
|
36
|
my ($hour, $min, $sec_mili) = split m/:/ms, $self->time; |
|
59
|
2
|
|
|
|
|
28
|
my ($sec, $mili) = split m/\./ms, $sec_mili; |
|
60
|
2
|
100
|
|
|
|
9
|
if (! defined $mili) { |
|
61
|
1
|
|
|
|
|
2
|
$mili = 0; |
|
62
|
|
|
|
|
|
|
} |
|
63
|
2
|
|
|
|
|
4
|
my $dt = eval { |
|
64
|
2
|
|
|
|
|
14
|
DateTime->new( |
|
65
|
|
|
|
|
|
|
'year' => $year, |
|
66
|
|
|
|
|
|
|
'month' => $month, |
|
67
|
|
|
|
|
|
|
'day' => $day, |
|
68
|
|
|
|
|
|
|
'hour' => $hour, |
|
69
|
|
|
|
|
|
|
'minute' => $min, |
|
70
|
|
|
|
|
|
|
'second' => $sec, |
|
71
|
|
|
|
|
|
|
'nanosecond' => $mili * 1000, |
|
72
|
|
|
|
|
|
|
); |
|
73
|
|
|
|
|
|
|
}; |
|
74
|
2
|
50
|
|
|
|
594
|
if ($EVAL_ERROR) { |
|
75
|
0
|
|
|
|
|
0
|
err 'Cannot create DateTime object.', |
|
76
|
|
|
|
|
|
|
'Error', $EVAL_ERROR; |
|
77
|
|
|
|
|
|
|
} |
|
78
|
2
|
|
|
|
|
11
|
return $dt; |
|
79
|
|
|
|
|
|
|
} |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
1; |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
__END__ |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=pod |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=encoding utf8 |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 NAME |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Log::FreeSWITCH::Line::Data - Data object which represents FreeSWITCH log line. |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
use Log::FreeSWITCH::Line::Data; |
|
96
|
|
|
|
|
|
|
my $obj = Log::FreeSWITCH::Line::Data->new(%params); |
|
97
|
|
|
|
|
|
|
my $date = $obj->date; |
|
98
|
|
|
|
|
|
|
my $datetime_o = $obj->datetime_obj; |
|
99
|
|
|
|
|
|
|
my $file = $obj->file; |
|
100
|
|
|
|
|
|
|
my $file_line = $obj->file_line; |
|
101
|
|
|
|
|
|
|
my $message = $obj->message; |
|
102
|
|
|
|
|
|
|
my $raw = $obj->raw($raw); |
|
103
|
|
|
|
|
|
|
my $time = $obj->time; |
|
104
|
|
|
|
|
|
|
my $type = $obj->type; |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 METHODS |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=over 8 |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=item C<new(%params)> |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Constructor. |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=over 8 |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=item * C<date> |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Date of log entry. |
|
119
|
|
|
|
|
|
|
Format of date is 'YYYY-MM-DD'. |
|
120
|
|
|
|
|
|
|
It is required. |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=item * C<file> |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
File in log entry. |
|
125
|
|
|
|
|
|
|
It is required. |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=item * C<file_line> |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
File line in log entry. |
|
130
|
|
|
|
|
|
|
It is required. |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=item * C<message> |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Log message. |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=item * C<raw> |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
Raw FreeSWITCH log entry. |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=item * C<time> |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
Time of log entry. |
|
143
|
|
|
|
|
|
|
Format of time is 'HH:MM:SS'. |
|
144
|
|
|
|
|
|
|
It is required. |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=item * C<type> |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
Type of log entry. |
|
149
|
|
|
|
|
|
|
It is required. |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=back |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=item C<date()> |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
Get log entry date. |
|
156
|
|
|
|
|
|
|
Returns string with date in 'YYYY-MM-DD' format. |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=item C<datetime_obj()> |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
Get DateTime object. |
|
161
|
|
|
|
|
|
|
Returns DateTime object. |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=item C<file()> |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
Get file in log entry. |
|
166
|
|
|
|
|
|
|
Returns string. |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=item C<file_line()> |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
Get file line in log entry. |
|
171
|
|
|
|
|
|
|
Returns string. |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=item C<message()> |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
Get log message. |
|
176
|
|
|
|
|
|
|
Returns string. |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=item C<raw($raw)> |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
Get or set raw FreeSWITCH log entry. |
|
181
|
|
|
|
|
|
|
Returns string. |
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=item C<time()> |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
Get log entry time. |
|
186
|
|
|
|
|
|
|
Returns string with time in 'HH:MM:SS' format. |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=item C<type()> |
|
189
|
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
Get log entry type. |
|
191
|
|
|
|
|
|
|
Returns string. |
|
192
|
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=back |
|
194
|
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=head1 ERRORS |
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
new(): |
|
198
|
|
|
|
|
|
|
date required |
|
199
|
|
|
|
|
|
|
file required |
|
200
|
|
|
|
|
|
|
file_line required |
|
201
|
|
|
|
|
|
|
time required |
|
202
|
|
|
|
|
|
|
type required |
|
203
|
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
datetime_obj(): |
|
205
|
|
|
|
|
|
|
Cannot create DateTime object. |
|
206
|
|
|
|
|
|
|
Error: %s |
|
207
|
|
|
|
|
|
|
Cannot load 'DateTime' class. |
|
208
|
|
|
|
|
|
|
Error: %s |
|
209
|
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=head1 EXAMPLE |
|
211
|
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
# Pragmas. |
|
213
|
|
|
|
|
|
|
use strict; |
|
214
|
|
|
|
|
|
|
use warnings; |
|
215
|
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
# Module. |
|
217
|
|
|
|
|
|
|
use Log::FreeSWITCH::Line::Data; |
|
218
|
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
# Object. |
|
220
|
|
|
|
|
|
|
my $data_o = Log::FreeSWITCH::Line::Data->new( |
|
221
|
|
|
|
|
|
|
'date' => '2014-07-01', |
|
222
|
|
|
|
|
|
|
'file' => 'sofia.c', |
|
223
|
|
|
|
|
|
|
'file_line' => 4045, |
|
224
|
|
|
|
|
|
|
'message' => 'inbound-codec-prefs [PCMA]', |
|
225
|
|
|
|
|
|
|
'time' => '13:37:53.973562', |
|
226
|
|
|
|
|
|
|
'type' => 'DEBUG', |
|
227
|
|
|
|
|
|
|
); |
|
228
|
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
# Print out informations. |
|
230
|
|
|
|
|
|
|
print 'Date: '.$data_o->date."\n"; |
|
231
|
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
# Output: |
|
233
|
|
|
|
|
|
|
# Date: 2014-07-01 |
|
234
|
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
|
236
|
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
L<DateTime>, |
|
238
|
|
|
|
|
|
|
L<English>, |
|
239
|
|
|
|
|
|
|
L<Error::Pure::Always>, |
|
240
|
|
|
|
|
|
|
L<Error::Pure>, |
|
241
|
|
|
|
|
|
|
L<Mo>. |
|
242
|
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
244
|
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
=over |
|
246
|
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
=item L<Log::FreeSWITCH::Line> |
|
248
|
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
FreeSWITCH log line parsing and serializing. |
|
250
|
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
=back |
|
252
|
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
=head1 REPOSITORY |
|
254
|
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
L<https://github.com/tupinek/Log-FreeSWITCH-Line> |
|
256
|
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
=head1 AUTHOR |
|
258
|
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
Michal Å paÄek L<mailto:skim@cpan.org> |
|
260
|
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
L<http://skim.cz> |
|
262
|
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
|
264
|
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
© 2014-2015 Michal Å paÄek |
|
266
|
|
|
|
|
|
|
BSD 2-Clause License |
|
267
|
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
=head1 VERSION |
|
269
|
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
0.06 |
|
271
|
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
=cut |