line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Log::FreeSWITCH::Line::Data; |
2
|
|
|
|
|
|
|
|
3
|
15
|
|
|
15
|
|
140698
|
use strict; |
|
15
|
|
|
|
|
90
|
|
|
15
|
|
|
|
|
436
|
|
4
|
15
|
|
|
15
|
|
76
|
use warnings; |
|
15
|
|
|
|
|
1649
|
|
|
15
|
|
|
|
|
374
|
|
5
|
|
|
|
|
|
|
|
6
|
15
|
|
|
15
|
|
4452
|
use English; |
|
15
|
|
|
|
|
44059
|
|
|
15
|
|
|
|
|
83
|
|
7
|
15
|
|
|
15
|
|
14759
|
use Error::Pure::Always; |
|
15
|
|
|
|
|
82053
|
|
|
15
|
|
|
|
|
476
|
|
8
|
15
|
|
|
15
|
|
91
|
use Error::Pure qw(err); |
|
15
|
|
|
|
|
30
|
|
|
15
|
|
|
|
|
623
|
|
9
|
15
|
|
|
15
|
|
6560
|
use Mo qw(builder is required); |
|
15
|
|
|
|
|
7785
|
|
|
15
|
|
|
|
|
81
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = 0.08; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has date => ( |
14
|
|
|
|
|
|
|
'is' => 'ro', |
15
|
|
|
|
|
|
|
'required' => 1, |
16
|
|
|
|
|
|
|
); |
17
|
|
|
|
|
|
|
has datetime_obj => ( |
18
|
|
|
|
|
|
|
'is' => 'ro', |
19
|
|
|
|
|
|
|
'builder' => '_datetime', |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
has file => ( |
22
|
|
|
|
|
|
|
'is' => 'ro', |
23
|
|
|
|
|
|
|
'required' => 1, |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
has file_line => ( |
26
|
|
|
|
|
|
|
'is' => 'ro', |
27
|
|
|
|
|
|
|
'required' => 1, |
28
|
|
|
|
|
|
|
); |
29
|
|
|
|
|
|
|
has message => ( |
30
|
|
|
|
|
|
|
'is' => 'ro', |
31
|
|
|
|
|
|
|
); |
32
|
|
|
|
|
|
|
has raw => ( |
33
|
|
|
|
|
|
|
'is' => 'rw', |
34
|
|
|
|
|
|
|
); |
35
|
|
|
|
|
|
|
has time => ( |
36
|
|
|
|
|
|
|
'is' => 'ro', |
37
|
|
|
|
|
|
|
'required' => 1, |
38
|
|
|
|
|
|
|
); |
39
|
|
|
|
|
|
|
has type => ( |
40
|
|
|
|
|
|
|
'is' => 'ro', |
41
|
|
|
|
|
|
|
'required' => 1, |
42
|
|
|
|
|
|
|
); |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# Create DateTime object. |
45
|
|
|
|
|
|
|
sub _datetime { |
46
|
3
|
|
|
3
|
|
1397
|
my $self = shift; |
47
|
3
|
|
|
|
|
7
|
eval { |
48
|
3
|
|
|
|
|
941
|
require DateTime; |
49
|
|
|
|
|
|
|
}; |
50
|
3
|
50
|
|
|
|
556083
|
if ($EVAL_ERROR) { |
51
|
0
|
|
|
|
|
0
|
err "Cannot load 'DateTime' class.", |
52
|
|
|
|
|
|
|
'Error', $EVAL_ERROR; |
53
|
|
|
|
|
|
|
} |
54
|
3
|
|
|
|
|
41
|
my ($year, $month, $day) = split m/-/ms, $self->date; |
55
|
3
|
|
|
|
|
41
|
my ($hour, $min, $sec_mili) = split m/:/ms, $self->time; |
56
|
3
|
|
|
|
|
29
|
my ($sec, $mili) = split m/\./ms, $sec_mili; |
57
|
3
|
100
|
|
|
|
9
|
if (! defined $mili) { |
58
|
1
|
|
|
|
|
3
|
$mili = 0; |
59
|
|
|
|
|
|
|
} |
60
|
3
|
|
|
|
|
12
|
my $dt = eval { |
61
|
3
|
|
|
|
|
16
|
DateTime->new( |
62
|
|
|
|
|
|
|
'year' => $year, |
63
|
|
|
|
|
|
|
'month' => $month, |
64
|
|
|
|
|
|
|
'day' => $day, |
65
|
|
|
|
|
|
|
'hour' => $hour, |
66
|
|
|
|
|
|
|
'minute' => $min, |
67
|
|
|
|
|
|
|
'second' => $sec, |
68
|
|
|
|
|
|
|
'nanosecond' => $mili * 1000, |
69
|
|
|
|
|
|
|
); |
70
|
|
|
|
|
|
|
}; |
71
|
3
|
100
|
|
|
|
9530
|
if ($EVAL_ERROR) { |
72
|
1
|
|
|
|
|
6
|
err 'Cannot create DateTime object.', |
73
|
|
|
|
|
|
|
'Error', $EVAL_ERROR; |
74
|
|
|
|
|
|
|
} |
75
|
2
|
|
|
|
|
17
|
return $dt; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
1; |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
__END__ |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=pod |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=encoding utf8 |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 NAME |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Log::FreeSWITCH::Line::Data - Data object which represents FreeSWITCH log line. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 SYNOPSIS |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
use Log::FreeSWITCH::Line::Data; |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
my $obj = Log::FreeSWITCH::Line::Data->new(%params); |
95
|
|
|
|
|
|
|
my $date = $obj->date; |
96
|
|
|
|
|
|
|
my $datetime_o = $obj->datetime_obj; |
97
|
|
|
|
|
|
|
my $file = $obj->file; |
98
|
|
|
|
|
|
|
my $file_line = $obj->file_line; |
99
|
|
|
|
|
|
|
my $message = $obj->message; |
100
|
|
|
|
|
|
|
my $raw = $obj->raw($raw); |
101
|
|
|
|
|
|
|
my $time = $obj->time; |
102
|
|
|
|
|
|
|
my $type = $obj->type; |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 METHODS |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head2 C<new> |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
my $obj = Log::FreeSWITCH::Line::Data->new(%params); |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
Constructor. |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Returns instance of object. |
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
|
|
|
|
|
|
|
=head2 C<date> |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
my $date = $obj->date; |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
Get log entry date. |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
Returns string with date in 'YYYY-MM-DD' format. |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head2 C<datetime_obj> |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
my $datetime_o = $obj->datetime_obj; |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
Get DateTime object. |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
Returns DateTime object. |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=head2 C<file> |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
my $file = $obj->file; |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
Get file in log entry. |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
Returns string. |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=head2 C<file_line> |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
my $file_line = $obj->file_line; |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
Get file line in log entry. |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
Returns string. |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=head2 C<message> |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
my $message = $obj->message; |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
Get log message. |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
Returns string. |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=head2 C<raw> |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
my $raw = $obj->raw($raw); |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
Get or set raw FreeSWITCH log entry. |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
Returns string. |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=head2 C<time> |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
my $time = $obj->time; |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
Get log entry time. |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
Returns string with time in 'HH:MM:SS' format. |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
=head2 C<type> |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
my $type = $obj->type; |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
Get log entry type. |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
Returns string. |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
=head1 ERRORS |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
new(): |
220
|
|
|
|
|
|
|
date required |
221
|
|
|
|
|
|
|
file required |
222
|
|
|
|
|
|
|
file_line required |
223
|
|
|
|
|
|
|
time required |
224
|
|
|
|
|
|
|
type required |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
datetime_obj(): |
227
|
|
|
|
|
|
|
Cannot create DateTime object. |
228
|
|
|
|
|
|
|
Error: %s |
229
|
|
|
|
|
|
|
Cannot load 'DateTime' class. |
230
|
|
|
|
|
|
|
Error: %s |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
=head1 EXAMPLE |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
=for comment filename=log_line_data_object.pl |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
use strict; |
237
|
|
|
|
|
|
|
use warnings; |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
use Log::FreeSWITCH::Line::Data; |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
# Object. |
242
|
|
|
|
|
|
|
my $data_o = Log::FreeSWITCH::Line::Data->new( |
243
|
|
|
|
|
|
|
'date' => '2014-07-01', |
244
|
|
|
|
|
|
|
'file' => 'sofia.c', |
245
|
|
|
|
|
|
|
'file_line' => 4045, |
246
|
|
|
|
|
|
|
'message' => 'inbound-codec-prefs [PCMA]', |
247
|
|
|
|
|
|
|
'time' => '13:37:53.973562', |
248
|
|
|
|
|
|
|
'type' => 'DEBUG', |
249
|
|
|
|
|
|
|
); |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
# Print out informations. |
252
|
|
|
|
|
|
|
print 'Date: '.$data_o->date."\n"; |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
# Output: |
255
|
|
|
|
|
|
|
# Date: 2014-07-01 |
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
L<DateTime>, |
260
|
|
|
|
|
|
|
L<English>, |
261
|
|
|
|
|
|
|
L<Error::Pure::Always>, |
262
|
|
|
|
|
|
|
L<Error::Pure>, |
263
|
|
|
|
|
|
|
L<Mo>. |
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
=head1 SEE ALSO |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
=over |
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
=item L<Log::FreeSWITCH::Line> |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
FreeSWITCH log line parsing and serializing. |
272
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
=back |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
=head1 REPOSITORY |
276
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
L<https://github.com/michal-josef-spacek/Log-FreeSWITCH-Line> |
278
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
=head1 AUTHOR |
280
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
Michal Josef Špaček L<mailto:skim@cpan.org> |
282
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
L<http://skim.cz> |
284
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
286
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
© 2014-2022 Michal Josef Špaček |
288
|
|
|
|
|
|
|
|
289
|
|
|
|
|
|
|
BSD 2-Clause License |
290
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
=head1 VERSION |
292
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
0.08 |
294
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
=cut |