line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::DTO::GELF; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: The DTO object for GELF version 1.1 |
4
|
|
|
|
|
|
|
our $VERSION = '1.7'; # VERSION 1.7 |
5
|
|
|
|
|
|
|
our $VERSION = 1.7; |
6
|
5
|
|
|
5
|
|
704168
|
use strict; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
123
|
|
7
|
5
|
|
|
5
|
|
23
|
use warnings; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
139
|
|
8
|
|
|
|
|
|
|
|
9
|
5
|
|
|
5
|
|
2116
|
use Moose; |
|
5
|
|
|
|
|
1629070
|
|
|
5
|
|
|
|
|
43
|
|
10
|
5
|
|
|
5
|
|
37276
|
use namespace::autoclean; |
|
5
|
|
|
|
|
33246
|
|
|
5
|
|
|
|
|
21
|
|
11
|
|
|
|
|
|
|
|
12
|
5
|
|
|
5
|
|
2327
|
use JSON::Tiny qw(encode_json); |
|
5
|
|
|
|
|
49106
|
|
|
5
|
|
|
|
|
337
|
|
13
|
5
|
|
|
5
|
|
789
|
use Sys::Hostname; |
|
5
|
|
|
|
|
1535
|
|
|
5
|
|
|
|
|
270
|
|
14
|
5
|
|
|
5
|
|
739
|
use Data::UUID; |
|
5
|
|
|
|
|
945
|
|
|
5
|
|
|
|
|
248
|
|
15
|
5
|
|
|
5
|
|
789
|
use POSIX qw(strftime); |
|
5
|
|
|
|
|
11384
|
|
|
5
|
|
|
|
|
36
|
|
16
|
|
|
|
|
|
|
|
17
|
5
|
|
|
5
|
|
4566
|
use Log::Log4perl; |
|
5
|
|
|
|
|
102249
|
|
|
5
|
|
|
|
|
38
|
|
18
|
|
|
|
|
|
|
|
19
|
5
|
|
|
5
|
|
2643
|
use Data::DTO::GELF::Types qw( LogLevel ); |
|
5
|
|
|
|
|
20
|
|
|
5
|
|
|
|
|
59
|
|
20
|
5
|
|
|
5
|
|
6393
|
use Devel::StackTrace; |
|
5
|
|
|
|
|
4963
|
|
|
5
|
|
|
|
|
2762
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
our $GELF_VERSION = 1.1; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
has 'version' => ( |
25
|
|
|
|
|
|
|
is => 'ro', |
26
|
|
|
|
|
|
|
isa => 'Str', |
27
|
|
|
|
|
|
|
builder => '_build_version', |
28
|
|
|
|
|
|
|
); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
has 'host' => ( |
31
|
|
|
|
|
|
|
is => 'rw', |
32
|
|
|
|
|
|
|
isa => 'Str', |
33
|
|
|
|
|
|
|
builder => '_build_host', |
34
|
|
|
|
|
|
|
); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
has 'short_message' => ( |
37
|
|
|
|
|
|
|
is => 'rw', |
38
|
|
|
|
|
|
|
isa => 'Str', |
39
|
|
|
|
|
|
|
lazy => 1, |
40
|
|
|
|
|
|
|
builder => '_long_to_short' |
41
|
|
|
|
|
|
|
); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
has 'full_message' => ( |
44
|
|
|
|
|
|
|
is => 'rw', |
45
|
|
|
|
|
|
|
isa => 'Str', |
46
|
|
|
|
|
|
|
); |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
has 'timestamp' => ( |
49
|
|
|
|
|
|
|
is => 'ro', |
50
|
|
|
|
|
|
|
isa => 'Int', |
51
|
|
|
|
|
|
|
builder => '_build_timestamp', |
52
|
|
|
|
|
|
|
); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
has 'level' => ( |
55
|
|
|
|
|
|
|
is => 'ro', |
56
|
|
|
|
|
|
|
isa => LogLevel, |
57
|
|
|
|
|
|
|
coerce => 1, |
58
|
|
|
|
|
|
|
); |
59
|
|
|
|
|
|
|
has '_facility' => ( |
60
|
|
|
|
|
|
|
is => 'rw', |
61
|
|
|
|
|
|
|
isa => 'Str', |
62
|
|
|
|
|
|
|
); |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
has '_line' => ( |
65
|
|
|
|
|
|
|
is => 'rw', |
66
|
|
|
|
|
|
|
isa => 'Int', |
67
|
|
|
|
|
|
|
); |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
has '_file' => ( |
70
|
|
|
|
|
|
|
is => 'rw', |
71
|
|
|
|
|
|
|
isa => 'Str', |
72
|
|
|
|
|
|
|
); |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub BUILD { |
75
|
3
|
|
|
3
|
0
|
9748
|
my $self = shift; |
76
|
3
|
|
|
|
|
8
|
my $args = shift; |
77
|
3
|
|
|
|
|
8
|
foreach my $key1 ( keys %{$args} ) { |
|
3
|
|
|
|
|
16
|
|
78
|
18
|
100
|
|
|
|
1888
|
if ( ( substr $key1, 0, 1 ) eq "_" ) { |
79
|
10
|
|
|
|
|
47
|
$self->meta->add_attribute( "$key1" => ( accessor => $key1 ) ); |
80
|
|
|
|
|
|
|
$self->meta->get_attribute($key1) |
81
|
10
|
|
|
|
|
29804
|
->set_value( $self, $args->{$key1} ); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
3
|
|
|
|
|
547
|
my $trace = Devel::StackTrace->new; |
86
|
3
|
|
|
|
|
1812
|
foreach my $frame ( $trace->frames ) { |
87
|
43
|
100
|
|
|
|
2279
|
if ( $frame->{subroutine} eq "Log::Log4perl::Logger::__ANON__" ) { |
88
|
4
|
|
|
|
|
140
|
$self->_line( $frame->{line} ); |
89
|
4
|
|
|
|
|
106
|
$self->_file( $frame->{filename} ); |
90
|
4
|
|
|
|
|
105
|
$self->_facility( $frame->{package} ); |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub _build_version { |
97
|
3
|
|
|
3
|
|
2621
|
my $self = shift; |
98
|
3
|
|
|
|
|
41
|
return "$GELF_VERSION"; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub _build_host { |
102
|
1
|
|
|
1
|
|
436
|
my $self = shift; |
103
|
1
|
|
|
|
|
7
|
return hostname(); |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub _build_timestamp { |
107
|
3
|
|
|
3
|
|
6190
|
my $self = shift; |
108
|
3
|
|
|
|
|
30
|
return time(); |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub message { |
112
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
113
|
0
|
|
|
|
|
0
|
my $m = shift; |
114
|
0
|
0
|
|
|
|
0
|
if ( defined $m ) { |
115
|
0
|
|
|
|
|
0
|
$self->full_message($m); |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
else { |
118
|
0
|
|
|
|
|
0
|
return $self->full_message(); |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
0
|
|
|
|
|
0
|
return; |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
sub _long_to_short { |
125
|
3
|
|
|
3
|
|
11
|
my $self = shift; |
126
|
3
|
|
|
|
|
110
|
my $msg = $self->full_message(); |
127
|
3
|
|
|
|
|
14
|
$msg =~ s/\n//sg; |
128
|
3
|
|
|
|
|
17
|
$msg =~ s/\s\s//sg; |
129
|
3
|
|
|
|
|
14
|
$msg = substr $msg, 0, 100; |
130
|
3
|
|
|
|
|
108
|
return $msg; |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
sub TO_HASH { |
134
|
2
|
|
|
2
|
0
|
11
|
my $self = shift; |
135
|
2
|
|
|
|
|
5
|
{ $self->short_message() } #fire off lazy message builder |
|
2
|
|
|
|
|
84
|
|
136
|
2
|
|
|
|
|
33
|
return {%$self}; |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
sub TO_JSON { |
140
|
1
|
|
|
1
|
0
|
3425
|
my $self = shift; |
141
|
1
|
|
|
|
|
4
|
{ $self->short_message() } #fire off lazy message builder |
|
1
|
|
|
|
|
47
|
|
142
|
1
|
|
|
|
|
28
|
return {%$self}; |
143
|
|
|
|
|
|
|
} |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
1; |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
__END__ |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=pod |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=encoding UTF-8 |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head1 NAME |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
Data::DTO::GELF - The DTO object for GELF version 1.1 |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=head1 VERSION |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
version 1.7 |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head1 AUTHOR |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
Brandon "Dimentox Travanti" Husbands <xotmid@gmail.com> |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
This software is copyright (c) 2017 by Brandon "Dimentox Travanti" Husbands. |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
170
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=cut |