line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
873
|
use strictures 2; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
39
|
|
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Dancer2::Logger::Radis; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
# ABSTRACT: Dancer2 logger engine for Log::Radis |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
167
|
use Moo 2; |
|
1
|
|
|
|
|
12
|
|
|
1
|
|
|
|
|
5
|
|
8
|
1
|
|
|
1
|
|
222
|
use Log::Radis 0.002; |
|
1
|
|
|
|
|
27
|
|
|
1
|
|
|
|
|
18
|
|
9
|
1
|
|
|
1
|
|
4
|
use Devel::StackTrace; |
|
1
|
|
|
|
|
0
|
|
|
1
|
|
|
|
|
324
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
with 'Dancer2::Core::Role::Logger'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our $VERSION = '0.001'; # VERSION |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
has server => ( |
18
|
|
|
|
|
|
|
is => 'ro', |
19
|
|
|
|
|
|
|
default => 'localhost:6379', |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
has reconnect => ( |
24
|
|
|
|
|
|
|
is => 'ro', |
25
|
|
|
|
|
|
|
default => 5, |
26
|
|
|
|
|
|
|
); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
has every => ( |
30
|
|
|
|
|
|
|
is => 'ro', |
31
|
|
|
|
|
|
|
default => 1, |
32
|
|
|
|
|
|
|
); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
has queue => ( |
36
|
|
|
|
|
|
|
is => 'ro', |
37
|
|
|
|
|
|
|
default => 'graylog-radis:queue', |
38
|
|
|
|
|
|
|
); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
has __mock => ( |
42
|
|
|
|
|
|
|
is => 'ro', |
43
|
|
|
|
|
|
|
); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
has _radis => ( |
46
|
|
|
|
|
|
|
is => 'lazy', |
47
|
|
|
|
|
|
|
builder => sub { |
48
|
1
|
|
|
1
|
|
303
|
my $self = shift; |
49
|
1
|
|
|
|
|
9
|
my %opts = ( |
50
|
|
|
|
|
|
|
server => $self->server, |
51
|
|
|
|
|
|
|
reconnect => $self->reconnect, |
52
|
|
|
|
|
|
|
every => $self->every, |
53
|
|
|
|
|
|
|
queue => $self->queue, |
54
|
|
|
|
|
|
|
); |
55
|
1
|
50
|
|
|
|
5
|
if ($self->__mock) { |
56
|
1
|
|
|
|
|
3
|
$opts{redis} = $self->__mock; |
57
|
|
|
|
|
|
|
} else { |
58
|
0
|
|
|
|
|
0
|
die('meh'); |
59
|
|
|
|
|
|
|
} |
60
|
1
|
|
|
|
|
5
|
Log::Radis->new(%opts); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
); |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub log { |
66
|
1
|
|
|
1
|
1
|
4032
|
my $self = shift; |
67
|
1
|
|
|
|
|
2
|
my ($level, $message) = @_; |
68
|
1
|
|
|
|
|
8
|
my $caller = Devel::StackTrace->new->frame(5); |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|
71
|
1
|
|
|
|
|
405
|
my %hash = ( |
72
|
|
|
|
|
|
|
_source => $self->app_name, |
73
|
|
|
|
|
|
|
_pid => $$, |
74
|
|
|
|
|
|
|
_package => $caller->package, |
75
|
|
|
|
|
|
|
_filename => $caller->filename, |
76
|
|
|
|
|
|
|
_line => $caller->line, |
77
|
|
|
|
|
|
|
); |
78
|
1
|
50
|
|
|
|
15
|
if (my $request = $self->request) { |
79
|
0
|
|
|
|
|
0
|
$hash{_http_id} = $request->id; |
80
|
0
|
|
|
|
|
0
|
$hash{_http_user} = $request->user; |
81
|
0
|
|
|
|
|
0
|
$hash{_http_client} = $request->address; |
82
|
0
|
|
|
|
|
0
|
$hash{_http_method} = $request->method; |
83
|
0
|
|
|
|
|
0
|
$hash{_http_path} = $request->path; |
84
|
0
|
|
|
|
|
0
|
$hash{_http_proto} = $request->protocol; |
85
|
0
|
|
|
|
|
0
|
$hash{_http_referer} = $request->header('referer'); |
86
|
0
|
|
|
|
|
0
|
$hash{_http_useragent} = $request->header('user_agent'); |
87
|
0
|
0
|
|
|
|
0
|
if ($self->_has_session) { |
88
|
0
|
|
|
|
|
0
|
$hash{_session_id} = $request->session->id; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
} |
91
|
1
|
|
|
|
|
3
|
$self->_radis->log($level, $message, %hash); |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
1; |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
__END__ |