line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Log::FreeSWITCH::Line::Data; |
2
|
|
|
|
|
|
|
|
3
|
15
|
|
|
15
|
|
132664
|
use strict; |
|
15
|
|
|
|
|
77
|
|
|
15
|
|
|
|
|
391
|
|
4
|
15
|
|
|
15
|
|
72
|
use warnings; |
|
15
|
|
|
|
|
82
|
|
|
15
|
|
|
|
|
358
|
|
5
|
|
|
|
|
|
|
|
6
|
15
|
|
|
15
|
|
5099
|
use English; |
|
15
|
|
|
|
|
33982
|
|
|
15
|
|
|
|
|
72
|
|
7
|
15
|
|
|
15
|
|
22338
|
use Error::Pure::Always; |
|
15
|
|
|
|
|
76254
|
|
|
15
|
|
|
|
|
430
|
|
8
|
15
|
|
|
15
|
|
94
|
use Error::Pure qw(err); |
|
15
|
|
|
|
|
28
|
|
|
15
|
|
|
|
|
4221
|
|
9
|
15
|
|
|
15
|
|
6527
|
use Mo qw(builder is required); |
|
15
|
|
|
|
|
9196
|
|
|
15
|
|
|
|
|
2333
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = 0.07; |
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
|
2
|
|
|
2
|
|
841
|
my $self = shift; |
47
|
2
|
|
|
|
|
3
|
eval { |
48
|
2
|
|
|
|
|
1019
|
require DateTime; |
49
|
|
|
|
|
|
|
}; |
50
|
2
|
50
|
|
|
|
497382
|
if ($EVAL_ERROR) { |
51
|
0
|
|
|
|
|
0
|
err "Cannot load 'DateTime' class.", |
52
|
|
|
|
|
|
|
'Error', $EVAL_ERROR; |
53
|
|
|
|
|
|
|
} |
54
|
2
|
|
|
|
|
38
|
my ($year, $month, $day) = split m/-/ms, $self->date; |
55
|
2
|
|
|
|
|
28
|
my ($hour, $min, $sec_mili) = split m/:/ms, $self->time; |
56
|
2
|
|
|
|
|
16
|
my ($sec, $mili) = split m/\./ms, $sec_mili; |
57
|
2
|
100
|
|
|
|
5
|
if (! defined $mili) { |
58
|
1
|
|
|
|
|
2
|
$mili = 0; |
59
|
|
|
|
|
|
|
} |
60
|
2
|
|
|
|
|
8
|
my $dt = eval { |
61
|
2
|
|
|
|
|
10
|
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
|
2
|
50
|
|
|
|
665
|
if ($EVAL_ERROR) { |
72
|
0
|
|
|
|
|
0
|
err 'Cannot create DateTime object.', |
73
|
|
|
|
|
|
|
'Error', $EVAL_ERROR; |
74
|
|
|
|
|
|
|
} |
75
|
2
|
|
|
|
|
16
|
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
|
|
|
|
|
|
|
=over 8 |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=item C<new(%params)> |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
Constructor. |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=over 8 |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=item * C<date> |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Date of log entry. |
117
|
|
|
|
|
|
|
Format of date is 'YYYY-MM-DD'. |
118
|
|
|
|
|
|
|
It is required. |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=item * C<file> |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
File in log entry. |
123
|
|
|
|
|
|
|
It is required. |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=item * C<file_line> |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
File line in log entry. |
128
|
|
|
|
|
|
|
It is required. |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=item * C<message> |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
Log message. |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=item * C<raw> |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
Raw FreeSWITCH log entry. |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=item * C<time> |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
Time of log entry. |
141
|
|
|
|
|
|
|
Format of time is 'HH:MM:SS'. |
142
|
|
|
|
|
|
|
It is required. |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=item * C<type> |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
Type of log entry. |
147
|
|
|
|
|
|
|
It is required. |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=back |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=item C<date()> |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
Get log entry date. |
154
|
|
|
|
|
|
|
Returns string with date in 'YYYY-MM-DD' format. |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=item C<datetime_obj()> |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
Get DateTime object. |
159
|
|
|
|
|
|
|
Returns DateTime object. |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=item C<file()> |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
Get file in log entry. |
164
|
|
|
|
|
|
|
Returns string. |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=item C<file_line()> |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
Get file line in log entry. |
169
|
|
|
|
|
|
|
Returns string. |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=item C<message()> |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
Get log message. |
174
|
|
|
|
|
|
|
Returns string. |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=item C<raw($raw)> |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
Get or set raw FreeSWITCH log entry. |
179
|
|
|
|
|
|
|
Returns string. |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=item C<time()> |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
Get log entry time. |
184
|
|
|
|
|
|
|
Returns string with time in 'HH:MM:SS' format. |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=item C<type()> |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
Get log entry type. |
189
|
|
|
|
|
|
|
Returns string. |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=back |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=head1 ERRORS |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
new(): |
196
|
|
|
|
|
|
|
date required |
197
|
|
|
|
|
|
|
file required |
198
|
|
|
|
|
|
|
file_line required |
199
|
|
|
|
|
|
|
time required |
200
|
|
|
|
|
|
|
type required |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
datetime_obj(): |
203
|
|
|
|
|
|
|
Cannot create DateTime object. |
204
|
|
|
|
|
|
|
Error: %s |
205
|
|
|
|
|
|
|
Cannot load 'DateTime' class. |
206
|
|
|
|
|
|
|
Error: %s |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
=head1 EXAMPLE |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
use strict; |
211
|
|
|
|
|
|
|
use warnings; |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
use Log::FreeSWITCH::Line::Data; |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
# Object. |
216
|
|
|
|
|
|
|
my $data_o = Log::FreeSWITCH::Line::Data->new( |
217
|
|
|
|
|
|
|
'date' => '2014-07-01', |
218
|
|
|
|
|
|
|
'file' => 'sofia.c', |
219
|
|
|
|
|
|
|
'file_line' => 4045, |
220
|
|
|
|
|
|
|
'message' => 'inbound-codec-prefs [PCMA]', |
221
|
|
|
|
|
|
|
'time' => '13:37:53.973562', |
222
|
|
|
|
|
|
|
'type' => 'DEBUG', |
223
|
|
|
|
|
|
|
); |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
# Print out informations. |
226
|
|
|
|
|
|
|
print 'Date: '.$data_o->date."\n"; |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
# Output: |
229
|
|
|
|
|
|
|
# Date: 2014-07-01 |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
L<DateTime>, |
234
|
|
|
|
|
|
|
L<English>, |
235
|
|
|
|
|
|
|
L<Error::Pure::Always>, |
236
|
|
|
|
|
|
|
L<Error::Pure>, |
237
|
|
|
|
|
|
|
L<Mo>. |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
=head1 SEE ALSO |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
=over |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
=item L<Log::FreeSWITCH::Line> |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
FreeSWITCH log line parsing and serializing. |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
=back |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
=head1 REPOSITORY |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
L<https://github.com/michal-josef-spacek/Log-FreeSWITCH-Line> |
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
=head1 AUTHOR |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
Michal Josef Špaček L<mailto:skim@cpan.org> |
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
L<http://skim.cz> |
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
© 2014-2021 Michal Josef Špaček |
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
BSD 2-Clause License |
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
=head1 VERSION |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
0.07 |
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
=cut |