line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyrights 2007-2017 by [Mark Overmeer]. |
2
|
|
|
|
|
|
|
# For other contributors see ChangeLog. |
3
|
|
|
|
|
|
|
# See the manual pages for details on the licensing terms. |
4
|
|
|
|
|
|
|
# Pod stripped from pm file by OODoc 2.02. |
5
|
15
|
|
|
15
|
|
90
|
use warnings; |
|
15
|
|
|
|
|
28
|
|
|
15
|
|
|
|
|
459
|
|
6
|
15
|
|
|
15
|
|
71
|
use strict; |
|
15
|
|
|
|
|
28
|
|
|
15
|
|
|
|
|
395
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
package Log::Report::Dispatcher::Try; |
9
|
15
|
|
|
15
|
|
67
|
use vars '$VERSION'; |
|
15
|
|
|
|
|
31
|
|
|
15
|
|
|
|
|
687
|
|
10
|
|
|
|
|
|
|
$VERSION = '1.23'; |
11
|
|
|
|
|
|
|
|
12
|
15
|
|
|
15
|
|
76
|
use base 'Log::Report::Dispatcher'; |
|
15
|
|
|
|
|
39
|
|
|
15
|
|
|
|
|
1726
|
|
13
|
|
|
|
|
|
|
|
14
|
15
|
|
|
15
|
|
91
|
use Log::Report 'log-report', syntax => 'SHORT'; |
|
15
|
|
|
|
|
32
|
|
|
15
|
|
|
|
|
100
|
|
15
|
15
|
|
|
15
|
|
85
|
use Log::Report::Exception (); |
|
15
|
|
|
|
|
26
|
|
|
15
|
|
|
|
|
286
|
|
16
|
15
|
|
|
15
|
|
70
|
use Log::Report::Util qw/%reason_code/; |
|
15
|
|
|
|
|
30
|
|
|
15
|
|
|
|
|
1247
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
use overload |
20
|
15
|
|
|
|
|
87
|
bool => 'failed' |
21
|
|
|
|
|
|
|
, '""' => 'showStatus' |
22
|
15
|
|
|
15
|
|
86
|
, fallback => 1; |
|
15
|
|
|
|
|
46
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
#----------------- |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub init($) |
27
|
17
|
|
|
17
|
0
|
79
|
{ my ($self, $args) = @_; |
28
|
17
|
50
|
|
|
|
65
|
defined $self->SUPER::init($args) or return; |
29
|
17
|
|
50
|
|
|
74
|
$self->{exceptions} = delete $args->{exceptions} || []; |
30
|
17
|
|
|
|
|
37
|
$self->{died} = delete $args->{died}; |
31
|
17
|
|
50
|
|
|
101
|
$self->hide($args->{hide} // 'NONE'); |
32
|
17
|
|
50
|
|
|
72
|
$self->{on_die} = $args->{on_die} // 'ERROR'; |
33
|
17
|
|
|
|
|
58
|
$self; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
#----------------- |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub died(;$) |
39
|
16
|
|
|
16
|
1
|
64
|
{ my $self = shift; |
40
|
16
|
100
|
|
|
|
53
|
@_ ? ($self->{died} = shift) : $self->{died}; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
44
|
4
|
|
|
4
|
1
|
7
|
sub exceptions() { @{shift->{exceptions}} } |
|
4
|
|
|
|
|
19
|
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub hides($) |
48
|
1
|
50
|
|
1
|
1
|
10
|
{ my $h = shift->{hides} or return 0; |
49
|
0
|
0
|
|
|
|
0
|
keys %$h ? $h->{(shift)} : 1; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub hide(@) |
54
|
17
|
|
|
17
|
1
|
29
|
{ my $self = shift; |
55
|
17
|
50
|
|
|
|
40
|
my @h = map { ref $_ eq 'ARRAY' ? @$_ : defined($_) ? $_ : () } @_; |
|
17
|
50
|
|
|
|
92
|
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
$self->{hides} |
58
|
17
|
50
|
33
|
|
|
168
|
= @h==0 ? undef |
|
|
50
|
33
|
|
|
|
|
|
|
50
|
|
|
|
|
|
59
|
|
|
|
|
|
|
: @h==1 && $h[0] eq 'ALL' ? {} # empty HASH = ALL |
60
|
|
|
|
|
|
|
: @h==1 && $h[0] eq 'NONE' ? undef |
61
|
|
|
|
|
|
|
: +{ map +($_ => 1), @h }; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
|
65
|
6
|
|
|
6
|
1
|
24
|
sub die2reason() { shift->{on_die} } |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
#----------------- |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub log($$$$) |
70
|
14
|
|
|
14
|
1
|
42
|
{ my ($self, $opts, $reason, $message, $domain) = @_; |
71
|
|
|
|
|
|
|
|
72
|
14
|
100
|
|
|
|
85
|
unless($opts->{stack}) |
73
|
6
|
|
|
|
|
37
|
{ my $mode = $self->mode; |
74
|
|
|
|
|
|
|
$opts->{stack} = $self->collectStack |
75
|
|
|
|
|
|
|
if $reason eq 'PANIC' |
76
|
|
|
|
|
|
|
|| ($mode==2 && $reason_code{$reason} >= $reason_code{ALERT}) |
77
|
6
|
100
|
33
|
|
|
94
|
|| ($mode==3 && $reason_code{$reason} >= $reason_code{ERROR}); |
|
|
|
33
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
66
|
|
|
|
|
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
14
|
|
100
|
|
|
46
|
$opts->{location} ||= ''; |
81
|
|
|
|
|
|
|
|
82
|
14
|
|
|
|
|
73
|
my $e = Log::Report::Exception->new |
83
|
|
|
|
|
|
|
( reason => $reason |
84
|
|
|
|
|
|
|
, report_opts => $opts |
85
|
|
|
|
|
|
|
, message => $message |
86
|
|
|
|
|
|
|
); |
87
|
|
|
|
|
|
|
|
88
|
14
|
|
|
|
|
25
|
push @{$self->{exceptions}}, $e; |
|
14
|
|
|
|
|
69
|
|
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
# $self->{died} ||= |
91
|
|
|
|
|
|
|
# exists $opts->{is_fatal} ? $opts->{is_fatal} : $e->isFatal; |
92
|
|
|
|
|
|
|
|
93
|
14
|
|
|
|
|
39
|
$self; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
|
97
|
0
|
|
|
0
|
1
|
0
|
sub reportFatal(@) { $_->throw(@_) for shift->wasFatal } |
98
|
2
|
|
|
2
|
1
|
12
|
sub reportAll(@) { $_->throw(@_) for shift->exceptions } |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
#----------------- |
101
|
|
|
|
|
|
|
|
102
|
5
|
|
|
5
|
1
|
188
|
sub failed() { defined shift->{died}} |
103
|
0
|
|
|
0
|
1
|
0
|
sub success() { ! defined shift->{died}} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub wasFatal(@) |
108
|
22
|
|
|
22
|
1
|
4362
|
{ my ($self, %args) = @_; |
109
|
22
|
100
|
|
|
|
110
|
defined $self->{died} or return (); |
110
|
|
|
|
|
|
|
|
111
|
15
|
|
|
|
|
30
|
my $ex = $self->{exceptions}[-1]; |
112
|
15
|
50
|
66
|
|
|
86
|
(!$args{class} || $ex->inClass($args{class})) ? $ex : (); |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
sub showStatus() |
117
|
3
|
|
|
3
|
1
|
7
|
{ my $self = shift; |
118
|
3
|
50
|
|
|
|
8
|
my $fatal = $self->wasFatal or return ''; |
119
|
3
|
|
|
|
|
8
|
__x"try-block stopped with {reason}: {text}" |
120
|
|
|
|
|
|
|
, reason => $fatal->reason |
121
|
|
|
|
|
|
|
, text => $self->died; |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
1; |