Update upstream source from tag 'upstream/1.32'
Update to upstream version '1.32'
with Debian dir 55b4dd3da6ae3ba45d4eff1f2d6958ecfcbca03e
gregor herrmann
3 years ago
5 | 5 | |
6 | 6 | TODO: |
7 | 7 | . connect to Message::Passing framework |
8 | ||
9 | version 1.32: Tue 26 Jan 09:13:31 CET 2021 | |
10 | ||
11 | Fixes: | |
12 | - ::Dancer2, use correct VERSION, github issue#3 | |
13 | - ::Dancer2, fix stacktrace sent to browser with show_errors disabled | |
14 | by [Andy Beverley], github issue#7 | |
15 | ||
16 | version 1.31: Fri 15 Jan 16:35:39 CET 2021 | |
17 | ||
18 | Fixes: | |
19 | - another attempt on issue #6, exceptions with specific destination | |
20 | are not caught by ::Try | |
21 | - previous release broke ::Try::hide() [Andy Beverley] | |
22 | ||
23 | version 1.30: Fri 15 Jan 12:46:14 CET 2021 | |
24 | ||
25 | Fixes: | |
26 | - recursive errors when file cannot be written for ::File dispatcher | |
27 | github issue#4 [Tom Hukins] | |
28 | - exceptions with specific destination are not caught by ::Try | |
29 | github issue#6 [Andy Beverley] | |
30 | - redirected exception messages forget their explicit dispatcher | |
31 | destination. Github issue#6 | |
32 | ||
33 | Improvements: | |
34 | - use ::Util::expand_reasons() for ::Try::hide() | |
35 | - require Log::Report::Options 1.07 for more expand_reasons options | |
8 | 36 | |
9 | 37 | version 1.29: Fri 8 Nov 09:18:01 CET 2019 |
10 | 38 |
33 | 33 | "requires" : { |
34 | 34 | "Devel::GlobalDestruction" : "0.09", |
35 | 35 | "Encode" : "2.00", |
36 | "Log::Report::Optional" : "1.03", | |
36 | "Log::Report::Optional" : "1.07", | |
37 | 37 | "Scalar::Util" : "0", |
38 | 38 | "String::Print" : "0.91", |
39 | 39 | "Sys::Syslog" : "0.27", |
53 | 53 | "web" : "https://github.com/markov2/perl5-Log-Report" |
54 | 54 | } |
55 | 55 | }, |
56 | "version" : "1.29", | |
56 | "version" : "1.32", | |
57 | 57 | "x_serialization_backend" : "JSON::PP version 2.94" |
58 | 58 | } |
19 | 19 | requires: |
20 | 20 | Devel::GlobalDestruction: '0.09' |
21 | 21 | Encode: '2.00' |
22 | Log::Report::Optional: '1.03' | |
22 | Log::Report::Optional: '1.07' | |
23 | 23 | Scalar::Util: '0' |
24 | 24 | String::Print: '0.91' |
25 | 25 | Sys::Syslog: '0.27' |
28 | 28 | homepage: http://perl.overmeer.net/CPAN/ |
29 | 29 | license: http://dev.perl.org/licenses/ |
30 | 30 | repository: https://github.com/markov2/perl5-Log-Report.git |
31 | version: '1.29' | |
31 | version: '1.32' | |
32 | 32 | x_serialization_backend: 'CPAN::Meta::YAML version 0.011' |
1 | 1 | |
2 | 2 | use 5.010; |
3 | 3 | |
4 | my $version = '1.29'; | |
4 | my $version = '1.32'; | |
5 | 5 | |
6 | 6 | my %prereq = |
7 | 7 | ( Test::More => '0.86' |
9 | 9 | , Encode => '2.00' |
10 | 10 | , Scalar::Util => 0 |
11 | 11 | , Devel::GlobalDestruction => '0.09' |
12 | , Log::Report::Optional => '1.03' | |
12 | , Log::Report::Optional => '1.07' | |
13 | 13 | , String::Print => '0.91' |
14 | 14 | ); |
15 | 15 |
0 | === README for Log-Report version 1.28 | |
1 | = Generated on Tue May 14 09:25:07 2019 by OODoc 2.02 | |
0 | === README for Log-Report version 1.30 | |
1 | = Generated on Fri Jan 15 12:45:38 2021 by OODoc 2.02 | |
2 | 2 | |
3 | 3 | There are various ways to install this module: |
4 | 4 | |
8 | 8 | (2) if you use Windows, have a look at http://ppm.activestate.com/ |
9 | 9 | |
10 | 10 | (3) if you have downloaded this module manually (as root/administrator) |
11 | gzip -d Log-Report-1.28.tar.gz | |
12 | tar -xf Log-Report-1.28.tar | |
13 | cd Log-Report-1.28 | |
11 | gzip -d Log-Report-1.30.tar.gz | |
12 | tar -xf Log-Report-1.30.tar | |
13 | cd Log-Report-1.30 | |
14 | 14 | perl Makefile.PL |
15 | 15 | make # optional |
16 | 16 | make test # optional |
17 | 17 | make install |
18 | 18 | |
19 | 19 | For usage, see the included manual-pages or |
20 | http://search.cpan.org/dist/Log-Report-1.28/ | |
20 | http://search.cpan.org/dist/Log-Report-1.30/ | |
21 | 21 | |
22 | 22 | Please report problems to |
23 | 23 | http://rt.cpan.org/Dist/Display.html?Queue=Log-Report |
0 | # Copyrights 2007-2019 by [Mark Overmeer <markov@cpan.org>]. | |
0 | # Copyrights 2007-2021 by [Mark Overmeer <markov@cpan.org>]. | |
1 | 1 | # For other contributors see ChangeLog. |
2 | 2 | # See the manual pages for details on the licensing terms. |
3 | 3 | # Pod stripped from pm file by OODoc 2.02. |
7 | 7 | |
8 | 8 | package Dancer::Logger::LogReport; |
9 | 9 | use vars '$VERSION'; |
10 | $VERSION = '1.29'; | |
10 | $VERSION = '1.32'; | |
11 | 11 | |
12 | 12 | use base 'Dancer::Logger::Abstract', 'Exporter'; |
13 | 13 |
60 | 60 | |
61 | 61 | =head1 SEE ALSO |
62 | 62 | |
63 | This module is part of Log-Report distribution version 1.29, | |
64 | built on November 08, 2019. Website: F<http://perl.overmeer.net/CPAN/> | |
63 | This module is part of Log-Report distribution version 1.32, | |
64 | built on January 26, 2021. Website: F<http://perl.overmeer.net/CPAN/> | |
65 | 65 | |
66 | 66 | =head1 LICENSE |
67 | 67 | |
68 | Copyrights 2007-2019 by [Mark Overmeer <markov@cpan.org>]. For other contributors see ChangeLog. | |
68 | Copyrights 2007-2021 by [Mark Overmeer <markov@cpan.org>]. For other contributors see ChangeLog. | |
69 | 69 | |
70 | 70 | This program is free software; you can redistribute it and/or modify it |
71 | 71 | under the same terms as Perl itself. |
0 | # Copyrights 2007-2019 by [Mark Overmeer <markov@cpan.org>]. | |
0 | # Copyrights 2007-2021 by [Mark Overmeer <markov@cpan.org>]. | |
1 | 1 | # For other contributors see ChangeLog. |
2 | 2 | # See the manual pages for details on the licensing terms. |
3 | 3 | # Pod stripped from pm file by OODoc 2.02. |
7 | 7 | |
8 | 8 | package Dancer2::Logger::LogReport; |
9 | 9 | use vars '$VERSION'; |
10 | $VERSION = '1.29'; | |
10 | $VERSION = '1.32'; | |
11 | 11 | |
12 | 12 | # ABSTRACT: Dancer2 logger engine for Log::Report |
13 | 13 |
70 | 70 | |
71 | 71 | =head1 SEE ALSO |
72 | 72 | |
73 | This module is part of Log-Report distribution version 1.29, | |
74 | built on November 08, 2019. Website: F<http://perl.overmeer.net/CPAN/> | |
73 | This module is part of Log-Report distribution version 1.32, | |
74 | built on January 26, 2021. Website: F<http://perl.overmeer.net/CPAN/> | |
75 | 75 | |
76 | 76 | =head1 LICENSE |
77 | 77 | |
78 | Copyrights 2007-2019 by [Mark Overmeer <markov@cpan.org>]. For other contributors see ChangeLog. | |
78 | Copyrights 2007-2021 by [Mark Overmeer <markov@cpan.org>]. For other contributors see ChangeLog. | |
79 | 79 | |
80 | 80 | This program is free software; you can redistribute it and/or modify it |
81 | 81 | under the same terms as Perl itself. |
0 | # Copyrights 2007-2019 by [Mark Overmeer <markov@cpan.org>]. | |
0 | # Copyrights 2007-2021 by [Mark Overmeer <markov@cpan.org>]. | |
1 | 1 | # For other contributors see ChangeLog. |
2 | 2 | # See the manual pages for details on the licensing terms. |
3 | 3 | # Pod stripped from pm file by OODoc 2.02. |
7 | 7 | |
8 | 8 | package Dancer2::Plugin::LogReport::Message; |
9 | 9 | use vars '$VERSION'; |
10 | $VERSION = '1.29'; | |
10 | $VERSION = '1.32'; | |
11 | 11 | |
12 | 12 | use parent 'Log::Report::Message'; |
13 | 13 |
76 | 76 | |
77 | 77 | =head1 SEE ALSO |
78 | 78 | |
79 | This module is part of Log-Report distribution version 1.29, | |
80 | built on November 08, 2019. Website: F<http://perl.overmeer.net/CPAN/> | |
79 | This module is part of Log-Report distribution version 1.32, | |
80 | built on January 26, 2021. Website: F<http://perl.overmeer.net/CPAN/> | |
81 | 81 | |
82 | 82 | =head1 LICENSE |
83 | 83 | |
84 | Copyrights 2007-2019 by [Mark Overmeer <markov@cpan.org>]. For other contributors see ChangeLog. | |
84 | Copyrights 2007-2021 by [Mark Overmeer <markov@cpan.org>]. For other contributors see ChangeLog. | |
85 | 85 | |
86 | 86 | This program is free software; you can redistribute it and/or modify it |
87 | 87 | under the same terms as Perl itself. |
0 | # Copyrights 2007-2019 by [Mark Overmeer <markov@cpan.org>]. | |
0 | # Copyrights 2007-2021 by [Mark Overmeer <markov@cpan.org>]. | |
1 | 1 | # For other contributors see ChangeLog. |
2 | 2 | # See the manual pages for details on the licensing terms. |
3 | 3 | # Pod stripped from pm file by OODoc 2.02. |
7 | 7 | |
8 | 8 | package Dancer2::Plugin::LogReport; |
9 | 9 | use vars '$VERSION'; |
10 | $VERSION = '1.29'; | |
10 | $VERSION = '1.32'; | |
11 | 11 | |
12 | 12 | |
13 | 13 | use warnings; |
31 | 31 | { my $class = shift; |
32 | 32 | |
33 | 33 | # Import Log::Report into the caller. Import options get passed through |
34 | my $level = $Dancer2::VERSION > 0.166001 ? '+1' : '+2'; | |
34 | my $level = $Dancer2::Plugin::VERSION > 0.166001 ? '+1' : '+2'; | |
35 | 35 | Log::Report->import($level, @_, syntax => 'LONG'); |
36 | 36 | |
37 | 37 | # Ensure the overridden import method is called (from Exporter::Tiny) |
62 | 62 | name => 'core.app.route_exception', |
63 | 63 | code => sub { |
64 | 64 | my ($app, $error) = @_; |
65 | report 'PANIC' => $error; | |
65 | # If there is no request object then we are in an early hook | |
66 | # and Dancer will not handle an exception cleanly (which will | |
67 | # result in a stacktrace to the browser, a potential security | |
68 | # vulnerability). Therefore in this case do not raise as fatal. | |
69 | my $is_fatal = $app->request ? 1 : 0; | |
70 | report {is_fatal => $is_fatal}, 'PANIC' => $error; | |
66 | 71 | }, |
67 | 72 | ), |
68 | 73 | ); |
104 | 109 | my $sm = $settings->{session_messages} // \@default_reasons; |
105 | 110 | $session_messages{$_} = 1 |
106 | 111 | for ref $sm eq 'ARRAY' ? @$sm : $sm; |
107 | ||
108 | # In a production server, we don't want the end user seeing (unexpected) | |
109 | # exception messages, for both security and usability. If we detect | |
110 | # that this is a production server (show_errors is 0), then we change | |
111 | # the specific error to a generic error, when displayed to the user. | |
112 | # The message can be customised in the config file. | |
113 | my $fatal_error_message = $settings->{fatal_error_message} | |
114 | // "An unexpected error has occurred"; | |
115 | ||
116 | unless($dsl->app->config->{show_errors}) | |
117 | { $hide_real_message->{$_} = $fatal_error_message | |
118 | for qw/FAULT ALERT FAILURE PANIC/; | |
119 | } | |
120 | 112 | |
121 | 113 | if(my $forward_template = $settings->{forward_template}) |
122 | 114 | { # Add a route for the specified template |
213 | 205 | # for request(), which is used to access the cookies of a session. |
214 | 206 | return unless $app->request; |
215 | 207 | |
208 | # In a production server, we don't want the end user seeing (unexpected) | |
209 | # exception messages, for both security and usability. If we detect | |
210 | # that this is a production server (show_errors is 0), then we change | |
211 | # the specific error to a generic error, when displayed to the user. | |
212 | # The message can be customised in the config file. | |
213 | # We evaluate this each message to allow show_errors to be set in the | |
214 | # application (specifically makes testing a lot easier) | |
215 | my $fatal_error_message = !$dsl->app->config->{show_errors} | |
216 | && ($_settings->{fatal_error_message} // "An unexpected error has occurred"); | |
217 | $hide_real_message->{$_} = $fatal_error_message | |
218 | for qw/FAULT ALERT FAILURE PANIC/; | |
219 | ||
216 | 220 | my $r = $msg->reason; |
217 | 221 | if(my $newm = $hide_real_message->{$r}) |
218 | 222 | { $msg = __$newm; |
224 | 228 | push @$msgs, $msg; |
225 | 229 | $session->write($messages_variable => $msgs); |
226 | 230 | |
227 | return $dsl; | |
231 | return ($dsl || undef, $msg); | |
228 | 232 | } |
229 | 233 | |
230 | 234 | #------ |
231 | 235 | |
232 | 236 | sub _forward_home($) |
233 | { my $dsl = _message_add(shift) || _get_dsl(); | |
237 | { my ($dsl, $msg) = _message_add(shift); | |
238 | $dsl ||= _get_dsl(); | |
239 | ||
234 | 240 | my $page = $_settings->{forward_url} || '/'; |
235 | 241 | |
236 | # Don't forward if it's a GET request to the error page, as it will | |
237 | # cause a recursive loop. In this case, do nothing, and let dancer | |
238 | # handle it. | |
242 | # Don't forward if it's a GET request to the error page, as it will cause a | |
243 | # recursive loop. In this case, return the fatal error message as plain | |
244 | # text to render that instead. If we can't do that because it's too early | |
245 | # in the request, then let Dancer handle this with its default error | |
246 | # handling | |
239 | 247 | my $req = $dsl->app->request or return; |
240 | return if $req->uri eq $page && $req->is_get; | |
248 | ||
249 | $dsl->send_as(plain => "$msg") | |
250 | if $req->uri eq $page && $req->is_get; | |
241 | 251 | |
242 | 252 | $dsl->redirect($page); |
243 | 253 | } |
512 | 512 | |
513 | 513 | =head1 SEE ALSO |
514 | 514 | |
515 | This module is part of Log-Report distribution version 1.29, | |
516 | built on November 08, 2019. Website: F<http://perl.overmeer.net/CPAN/> | |
515 | This module is part of Log-Report distribution version 1.32, | |
516 | built on January 26, 2021. Website: F<http://perl.overmeer.net/CPAN/> | |
517 | 517 | |
518 | 518 | =head1 LICENSE |
519 | 519 | |
520 | Copyrights 2007-2019 by [Mark Overmeer <markov@cpan.org>]. For other contributors see ChangeLog. | |
520 | Copyrights 2007-2021 by [Mark Overmeer <markov@cpan.org>]. For other contributors see ChangeLog. | |
521 | 521 | |
522 | 522 | This program is free software; you can redistribute it and/or modify it |
523 | 523 | under the same terms as Perl itself. |
0 | # Copyrights 2007-2019 by [Mark Overmeer <markov@cpan.org>]. | |
0 | # Copyrights 2007-2021 by [Mark Overmeer <markov@cpan.org>]. | |
1 | 1 | # For other contributors see ChangeLog. |
2 | 2 | # See the manual pages for details on the licensing terms. |
3 | 3 | # Pod stripped from pm file by OODoc 2.02. |
7 | 7 | |
8 | 8 | package Log::Report::DBIC::Profiler; |
9 | 9 | use vars '$VERSION'; |
10 | $VERSION = '1.29'; | |
10 | $VERSION = '1.32'; | |
11 | 11 | |
12 | 12 | use base 'DBIx::Class::Storage::Statistics'; |
13 | 13 |
32 | 32 | |
33 | 33 | =head1 SEE ALSO |
34 | 34 | |
35 | This module is part of Log-Report distribution version 1.29, | |
36 | built on November 08, 2019. Website: F<http://perl.overmeer.net/CPAN/> | |
35 | This module is part of Log-Report distribution version 1.32, | |
36 | built on January 26, 2021. Website: F<http://perl.overmeer.net/CPAN/> | |
37 | 37 | |
38 | 38 | =head1 LICENSE |
39 | 39 | |
40 | Copyrights 2007-2019 by [Mark Overmeer <markov@cpan.org>]. For other contributors see ChangeLog. | |
40 | Copyrights 2007-2021 by [Mark Overmeer <markov@cpan.org>]. For other contributors see ChangeLog. | |
41 | 41 | |
42 | 42 | This program is free software; you can redistribute it and/or modify it |
43 | 43 | under the same terms as Perl itself. |
0 | # Copyrights 2007-2019 by [Mark Overmeer <markov@cpan.org>]. | |
0 | # Copyrights 2007-2021 by [Mark Overmeer <markov@cpan.org>]. | |
1 | 1 | # For other contributors see ChangeLog. |
2 | 2 | # See the manual pages for details on the licensing terms. |
3 | 3 | # Pod stripped from pm file by OODoc 2.02. |
7 | 7 | |
8 | 8 | package Log::Report::Die; |
9 | 9 | use vars '$VERSION'; |
10 | $VERSION = '1.29'; | |
10 | $VERSION = '1.32'; | |
11 | 11 | |
12 | 12 | use base 'Exporter'; |
13 | 13 |
77 | 77 | |
78 | 78 | =head1 SEE ALSO |
79 | 79 | |
80 | This module is part of Log-Report distribution version 1.29, | |
81 | built on November 08, 2019. Website: F<http://perl.overmeer.net/CPAN/> | |
80 | This module is part of Log-Report distribution version 1.32, | |
81 | built on January 26, 2021. Website: F<http://perl.overmeer.net/CPAN/> | |
82 | 82 | |
83 | 83 | =head1 LICENSE |
84 | 84 | |
85 | Copyrights 2007-2019 by [Mark Overmeer <markov@cpan.org>]. For other contributors see ChangeLog. | |
85 | Copyrights 2007-2021 by [Mark Overmeer <markov@cpan.org>]. For other contributors see ChangeLog. | |
86 | 86 | |
87 | 87 | This program is free software; you can redistribute it and/or modify it |
88 | 88 | under the same terms as Perl itself. |
0 | # Copyrights 2007-2019 by [Mark Overmeer <markov@cpan.org>]. | |
0 | # Copyrights 2007-2021 by [Mark Overmeer <markov@cpan.org>]. | |
1 | 1 | # For other contributors see ChangeLog. |
2 | 2 | # See the manual pages for details on the licensing terms. |
3 | 3 | # Pod stripped from pm file by OODoc 2.02. |
7 | 7 | |
8 | 8 | package Log::Report::Dispatcher::Callback; |
9 | 9 | use vars '$VERSION'; |
10 | $VERSION = '1.29'; | |
10 | $VERSION = '1.32'; | |
11 | 11 | |
12 | 12 | use base 'Log::Report::Dispatcher'; |
13 | 13 |
173 | 173 | |
174 | 174 | =head1 SEE ALSO |
175 | 175 | |
176 | This module is part of Log-Report distribution version 1.29, | |
177 | built on November 08, 2019. Website: F<http://perl.overmeer.net/CPAN/> | |
176 | This module is part of Log-Report distribution version 1.32, | |
177 | built on January 26, 2021. Website: F<http://perl.overmeer.net/CPAN/> | |
178 | 178 | |
179 | 179 | =head1 LICENSE |
180 | 180 | |
181 | Copyrights 2007-2019 by [Mark Overmeer <markov@cpan.org>]. For other contributors see ChangeLog. | |
181 | Copyrights 2007-2021 by [Mark Overmeer <markov@cpan.org>]. For other contributors see ChangeLog. | |
182 | 182 | |
183 | 183 | This program is free software; you can redistribute it and/or modify it |
184 | 184 | under the same terms as Perl itself. |
0 | # Copyrights 2007-2019 by [Mark Overmeer <markov@cpan.org>]. | |
0 | # Copyrights 2007-2021 by [Mark Overmeer <markov@cpan.org>]. | |
1 | 1 | # For other contributors see ChangeLog. |
2 | 2 | # See the manual pages for details on the licensing terms. |
3 | 3 | # Pod stripped from pm file by OODoc 2.02. |
7 | 7 | |
8 | 8 | package Log::Report::Dispatcher::File; |
9 | 9 | use vars '$VERSION'; |
10 | $VERSION = '1.29'; | |
10 | $VERSION = '1.32'; | |
11 | 11 | |
12 | 12 | use base 'Log::Report::Dispatcher'; |
13 | 13 | |
66 | 66 | : $self->{LRDF_filename} ? $self->{LRDF_output} |
67 | 67 | : (); |
68 | 68 | |
69 | $_->close for @close; | |
69 | $_ && $_->close for @close; | |
70 | 70 | $self; |
71 | 71 | } |
72 | 72 | |
89 | 89 | $self->{LRDF_filename} = $to; |
90 | 90 | my $binmode = $self->{replace} ? '>' : '>>'; |
91 | 91 | |
92 | my $f = $self->{LRDF_output} = IO::File->new($to, $binmode) | |
93 | or fault __x"cannot write log into {file} with mode {binmode}" | |
92 | my $f = $self->{LRDF_output} = IO::File->new($to, $binmode); | |
93 | unless($f) | |
94 | { # avoid logging error to myself (issue #4) | |
95 | my $msg = __x"cannot write log into {file} with mode '{binmode}'" | |
94 | 96 | , binmode => $binmode, file => $to; |
97 | if(my @disp = grep $_->name ne $name, Log::Report::dispatcher('list')) | |
98 | { $msg->to($disp[0]->name); | |
99 | error $msg; | |
100 | } | |
101 | else | |
102 | { die $msg; | |
103 | } | |
104 | } | |
105 | ||
95 | 106 | $f->autoflush; |
96 | 107 | return $self->{LRDF_output} = $f; |
97 | 108 | } |
258 | 258 | |
259 | 259 | =head1 SEE ALSO |
260 | 260 | |
261 | This module is part of Log-Report distribution version 1.29, | |
262 | built on November 08, 2019. Website: F<http://perl.overmeer.net/CPAN/> | |
261 | This module is part of Log-Report distribution version 1.32, | |
262 | built on January 26, 2021. Website: F<http://perl.overmeer.net/CPAN/> | |
263 | 263 | |
264 | 264 | =head1 LICENSE |
265 | 265 | |
266 | Copyrights 2007-2019 by [Mark Overmeer <markov@cpan.org>]. For other contributors see ChangeLog. | |
266 | Copyrights 2007-2021 by [Mark Overmeer <markov@cpan.org>]. For other contributors see ChangeLog. | |
267 | 267 | |
268 | 268 | This program is free software; you can redistribute it and/or modify it |
269 | 269 | under the same terms as Perl itself. |
0 | # Copyrights 2007-2019 by [Mark Overmeer <markov@cpan.org>]. | |
0 | # Copyrights 2007-2021 by [Mark Overmeer <markov@cpan.org>]. | |
1 | 1 | # For other contributors see ChangeLog. |
2 | 2 | # See the manual pages for details on the licensing terms. |
3 | 3 | # Pod stripped from pm file by OODoc 2.02. |
7 | 7 | |
8 | 8 | package Log::Report::Dispatcher::Log4perl; |
9 | 9 | use vars '$VERSION'; |
10 | $VERSION = '1.29'; | |
10 | $VERSION = '1.32'; | |
11 | 11 | |
12 | 12 | use base 'Log::Report::Dispatcher'; |
13 | 13 |
229 | 229 | |
230 | 230 | =head1 SEE ALSO |
231 | 231 | |
232 | This module is part of Log-Report distribution version 1.29, | |
233 | built on November 08, 2019. Website: F<http://perl.overmeer.net/CPAN/> | |
232 | This module is part of Log-Report distribution version 1.32, | |
233 | built on January 26, 2021. Website: F<http://perl.overmeer.net/CPAN/> | |
234 | 234 | |
235 | 235 | =head1 LICENSE |
236 | 236 | |
237 | Copyrights 2007-2019 by [Mark Overmeer <markov@cpan.org>]. For other contributors see ChangeLog. | |
237 | Copyrights 2007-2021 by [Mark Overmeer <markov@cpan.org>]. For other contributors see ChangeLog. | |
238 | 238 | |
239 | 239 | This program is free software; you can redistribute it and/or modify it |
240 | 240 | under the same terms as Perl itself. |
0 | # Copyrights 2007-2019 by [Mark Overmeer <markov@cpan.org>]. | |
0 | # Copyrights 2007-2021 by [Mark Overmeer <markov@cpan.org>]. | |
1 | 1 | # For other contributors see ChangeLog. |
2 | 2 | # See the manual pages for details on the licensing terms. |
3 | 3 | # Pod stripped from pm file by OODoc 2.02. |
7 | 7 | |
8 | 8 | package Log::Report::Dispatcher::LogDispatch; |
9 | 9 | use vars '$VERSION'; |
10 | $VERSION = '1.29'; | |
10 | $VERSION = '1.32'; | |
11 | 11 | |
12 | 12 | use base 'Log::Report::Dispatcher'; |
13 | 13 |
193 | 193 | |
194 | 194 | =head1 SEE ALSO |
195 | 195 | |
196 | This module is part of Log-Report distribution version 1.29, | |
197 | built on November 08, 2019. Website: F<http://perl.overmeer.net/CPAN/> | |
196 | This module is part of Log-Report distribution version 1.32, | |
197 | built on January 26, 2021. Website: F<http://perl.overmeer.net/CPAN/> | |
198 | 198 | |
199 | 199 | =head1 LICENSE |
200 | 200 | |
201 | Copyrights 2007-2019 by [Mark Overmeer <markov@cpan.org>]. For other contributors see ChangeLog. | |
201 | Copyrights 2007-2021 by [Mark Overmeer <markov@cpan.org>]. For other contributors see ChangeLog. | |
202 | 202 | |
203 | 203 | This program is free software; you can redistribute it and/or modify it |
204 | 204 | under the same terms as Perl itself. |
0 | # Copyrights 2007-2019 by [Mark Overmeer <markov@cpan.org>]. | |
0 | # Copyrights 2007-2021 by [Mark Overmeer <markov@cpan.org>]. | |
1 | 1 | # For other contributors see ChangeLog. |
2 | 2 | # See the manual pages for details on the licensing terms. |
3 | 3 | # Pod stripped from pm file by OODoc 2.02. |
7 | 7 | |
8 | 8 | package Log::Report::Dispatcher::Perl; |
9 | 9 | use vars '$VERSION'; |
10 | $VERSION = '1.29'; | |
10 | $VERSION = '1.32'; | |
11 | 11 | |
12 | 12 | use base 'Log::Report::Dispatcher'; |
13 | 13 |
38 | 38 | |
39 | 39 | =head1 SEE ALSO |
40 | 40 | |
41 | This module is part of Log-Report distribution version 1.29, | |
42 | built on November 08, 2019. Website: F<http://perl.overmeer.net/CPAN/> | |
41 | This module is part of Log-Report distribution version 1.32, | |
42 | built on January 26, 2021. Website: F<http://perl.overmeer.net/CPAN/> | |
43 | 43 | |
44 | 44 | =head1 LICENSE |
45 | 45 | |
46 | Copyrights 2007-2019 by [Mark Overmeer <markov@cpan.org>]. For other contributors see ChangeLog. | |
46 | Copyrights 2007-2021 by [Mark Overmeer <markov@cpan.org>]. For other contributors see ChangeLog. | |
47 | 47 | |
48 | 48 | This program is free software; you can redistribute it and/or modify it |
49 | 49 | under the same terms as Perl itself. |
0 | # Copyrights 2007-2019 by [Mark Overmeer <markov@cpan.org>]. | |
0 | # Copyrights 2007-2021 by [Mark Overmeer <markov@cpan.org>]. | |
1 | 1 | # For other contributors see ChangeLog. |
2 | 2 | # See the manual pages for details on the licensing terms. |
3 | 3 | # Pod stripped from pm file by OODoc 2.02. |
7 | 7 | |
8 | 8 | package Log::Report::Dispatcher::Syslog; |
9 | 9 | use vars '$VERSION'; |
10 | $VERSION = '1.29'; | |
10 | $VERSION = '1.32'; | |
11 | 11 | |
12 | 12 | use base 'Log::Report::Dispatcher'; |
13 | 13 |
222 | 222 | |
223 | 223 | =head1 SEE ALSO |
224 | 224 | |
225 | This module is part of Log-Report distribution version 1.29, | |
226 | built on November 08, 2019. Website: F<http://perl.overmeer.net/CPAN/> | |
225 | This module is part of Log-Report distribution version 1.32, | |
226 | built on January 26, 2021. Website: F<http://perl.overmeer.net/CPAN/> | |
227 | 227 | |
228 | 228 | =head1 LICENSE |
229 | 229 | |
230 | Copyrights 2007-2019 by [Mark Overmeer <markov@cpan.org>]. For other contributors see ChangeLog. | |
230 | Copyrights 2007-2021 by [Mark Overmeer <markov@cpan.org>]. For other contributors see ChangeLog. | |
231 | 231 | |
232 | 232 | This program is free software; you can redistribute it and/or modify it |
233 | 233 | under the same terms as Perl itself. |
0 | # Copyrights 2007-2019 by [Mark Overmeer <markov@cpan.org>]. | |
0 | # Copyrights 2007-2021 by [Mark Overmeer <markov@cpan.org>]. | |
1 | 1 | # For other contributors see ChangeLog. |
2 | 2 | # See the manual pages for details on the licensing terms. |
3 | 3 | # Pod stripped from pm file by OODoc 2.02. |
7 | 7 | |
8 | 8 | package Log::Report::Dispatcher::Try; |
9 | 9 | use vars '$VERSION'; |
10 | $VERSION = '1.29'; | |
10 | $VERSION = '1.32'; | |
11 | 11 | |
12 | 12 | use base 'Log::Report::Dispatcher'; |
13 | 13 | |
16 | 16 | |
17 | 17 | use Log::Report 'log-report', syntax => 'SHORT'; |
18 | 18 | use Log::Report::Exception (); |
19 | use Log::Report::Util qw/%reason_code/; | |
19 | use Log::Report::Util qw/%reason_code expand_reasons/; | |
20 | 20 | use List::Util qw/first/; |
21 | 21 | |
22 | 22 | |
48 | 48 | sub exceptions() { @{shift->{exceptions}} } |
49 | 49 | |
50 | 50 | |
51 | sub hides($) | |
52 | { my $h = shift->{hides} or return 0; | |
53 | keys %$h ? $h->{(shift)} : 1; | |
54 | } | |
51 | sub hides($) { $_[0]->{LRDT_hides}{$_[1]} } | |
55 | 52 | |
56 | 53 | |
57 | 54 | sub hide(@) |
58 | 55 | { my $self = shift; |
59 | my @h = map { ref $_ eq 'ARRAY' ? @$_ : defined($_) ? $_ : () } @_; | |
60 | ||
61 | $self->{hides} | |
62 | = @h==0 ? undef | |
63 | : @h==1 && $h[0] eq 'ALL' ? {} # empty HASH = ALL | |
64 | : @h==1 && $h[0] eq 'NONE' ? undef | |
65 | : +{ map +($_ => 1), @h }; | |
56 | my @reasons = expand_reasons(@_ > 1 ? \@_ : shift); | |
57 | $self->{LRDT_hides} = +{ map +($_ => 1), @reasons }; | |
66 | 58 | } |
67 | 59 | |
68 | 60 | |
107 | 99 | sub success() { ! defined shift->{died}} |
108 | 100 | |
109 | 101 | |
110 | ||
111 | 102 | sub wasFatal(@) |
112 | 103 | { my ($self, %args) = @_; |
113 | 104 | defined $self->{died} or return (); |
44 | 44 | |
45 | 45 | =head1 DESCRIPTION |
46 | 46 | |
47 | The L<Log::Report::try()|Log::Report/"Report Production and Configuration"> catches errors in the block (CODE | |
48 | reference) which is just following the function name. All | |
49 | dispatchers are temporarily disabled by C<try>, and messages | |
50 | which are reported are collected within a temporary dispatcher | |
51 | named C<try>. When the CODE has run, that C<try> dispatcher | |
52 | is returned in C<$@>, and all original dispatchers reinstated. | |
53 | ||
54 | Then, after the C<try> has finished, the routine which used | |
55 | the "try" should decide what to do with the collected reports. | |
56 | These reports are collected as L<Log::Report::Exception|Log::Report::Exception> objects. | |
57 | They can be ignored, or thrown to a higher level try... causing | |
58 | an exit of the program if there is none. | |
47 | The B<try> works like Perl's build-in C<eval()>, but implements | |
48 | real exception handling which Perl core lacks. | |
49 | ||
50 | The L<Log::Report::try()|Log::Report/"Report Production and Configuration"> function creates this C<::Try> dispatcher | |
51 | object with name 'try'. After the C<try()> is over, you can find | |
52 | the object in C<$@>. The C<$@> as C<::Try> object behaves exactly | |
53 | as the C<$@> produced by C<eval>, but has many added features. | |
54 | ||
55 | The C<try()> function catches fatal errors happening inside the BLOCK | |
56 | (CODE reference which is just following the function name) into the | |
57 | C<::Try> object C<$@>. The errors are not automatically progressed to | |
58 | active dispatchers. However, non-fatal exceptions (like info or notice) | |
59 | are also collected (unless not accepted, see L<new(accept)|Log::Report::Dispatcher/"Constructors">, but also | |
60 | immediately passed to the active dispatchers (unless the reason is hidden, | |
61 | see L<new(hide)|Log::Report::Dispatcher::Try/"Constructors">) | |
62 | ||
63 | After the C<try()> has run, you can introspect the collected exceptions. | |
64 | Typically, you use L<wasFatal()|Log::Report::Dispatcher::Try/"Status"> to get the exception which terminated | |
65 | the run of the BLOCK. | |
59 | 66 | |
60 | 67 | Extends L<"DESCRIPTION" in Log::Report::Dispatcher|Log::Report::Dispatcher/"DESCRIPTION">. |
61 | 68 | |
102 | 109 | |
103 | 110 | =item format_reason => 'UPPERCASE'|'LOWERCASE'|'UCFIRST'|'IGNORE'|CODE |
104 | 111 | |
105 | =item hide => REASON|ARRAY|'ALL'|'NONE' | |
112 | =item hide => REASONS|ARRAY|'ALL'|'NONE' | |
106 | 113 | |
107 | 114 | [1.09] see L<hide()|Log::Report::Dispatcher::Try/"Accessors"> |
108 | 115 | |
141 | 148 | Returns all collected C<Log::Report::Exceptions>. The last of |
142 | 149 | them may be a fatal one. The other are non-fatal. |
143 | 150 | |
144 | =item $obj-E<gt>B<hide>(REASON|REASONS|ARRAY|'ALL'|'NONE') | |
151 | =item $obj-E<gt>B<hide>(@reasons) | |
145 | 152 | |
146 | 153 | [1.09] By default, the try will only catch messages which stop the |
147 | 154 | execution of the block (errors etc, internally a 'die'). Other messages |
148 | are passed to parent try blocks, if none than to the dispatchers. | |
149 | ||
150 | This option gives the opportunity to block, for instance, trace messages. | |
151 | Those messages are still collected inside the try object, so may get | |
152 | passed-on later via L<reportAll()|Log::Report::Dispatcher::Try/"Logging"> if you like. | |
155 | are passed to the parent dispatchers. | |
156 | ||
157 | This option gives the opportunity to stop, for instance, trace messages. | |
158 | Those messages are still collected inside the try object (unless excluded | |
159 | by L<new(accept)|Log::Report::Dispatcher/"Constructors">), so may get passed-on later via L<reportAll()|Log::Report::Dispatcher::Try/"Logging"> if | |
160 | you like. | |
153 | 161 | |
154 | 162 | Be warned: Using this method will reset the whole 'hide' configuration: |
155 | 163 | it's a I<set> not an I<add>. |
157 | 165 | example: change the setting of the running block |
158 | 166 | |
159 | 167 | my $parent_try = dispatcher 'active-try'; |
160 | parent_try->hide('NONE'); | |
161 | ||
162 | =item $obj-E<gt>B<hides>(REASON) | |
168 | $parent_try->hide('ALL'); | |
169 | ||
170 | =item $obj-E<gt>B<hides>($reason) | |
171 | ||
172 | Check whether the try stops message which were produced for C<$reason>. | |
163 | 173 | |
164 | 174 | =item $obj-E<gt>B<isDisabled>() |
165 | 175 | |
311 | 321 | |
312 | 322 | =head1 SEE ALSO |
313 | 323 | |
314 | This module is part of Log-Report distribution version 1.29, | |
315 | built on November 08, 2019. Website: F<http://perl.overmeer.net/CPAN/> | |
324 | This module is part of Log-Report distribution version 1.32, | |
325 | built on January 26, 2021. Website: F<http://perl.overmeer.net/CPAN/> | |
316 | 326 | |
317 | 327 | =head1 LICENSE |
318 | 328 | |
319 | Copyrights 2007-2019 by [Mark Overmeer <markov@cpan.org>]. For other contributors see ChangeLog. | |
329 | Copyrights 2007-2021 by [Mark Overmeer <markov@cpan.org>]. For other contributors see ChangeLog. | |
320 | 330 | |
321 | 331 | This program is free software; you can redistribute it and/or modify it |
322 | 332 | under the same terms as Perl itself. |
0 | # Copyrights 2007-2019 by [Mark Overmeer <markov@cpan.org>]. | |
0 | # Copyrights 2007-2021 by [Mark Overmeer <markov@cpan.org>]. | |
1 | 1 | # For other contributors see ChangeLog. |
2 | 2 | # See the manual pages for details on the licensing terms. |
3 | 3 | # Pod stripped from pm file by OODoc 2.02. |
7 | 7 | |
8 | 8 | package Log::Report::Dispatcher; |
9 | 9 | use vars '$VERSION'; |
10 | $VERSION = '1.29'; | |
10 | $VERSION = '1.32'; | |
11 | 11 | |
12 | 12 | |
13 | 13 | use warnings; |
394 | 394 | |
395 | 395 | =head1 SEE ALSO |
396 | 396 | |
397 | This module is part of Log-Report distribution version 1.29, | |
398 | built on November 08, 2019. Website: F<http://perl.overmeer.net/CPAN/> | |
397 | This module is part of Log-Report distribution version 1.32, | |
398 | built on January 26, 2021. Website: F<http://perl.overmeer.net/CPAN/> | |
399 | 399 | |
400 | 400 | =head1 LICENSE |
401 | 401 | |
402 | Copyrights 2007-2019 by [Mark Overmeer <markov@cpan.org>]. For other contributors see ChangeLog. | |
402 | Copyrights 2007-2021 by [Mark Overmeer <markov@cpan.org>]. For other contributors see ChangeLog. | |
403 | 403 | |
404 | 404 | This program is free software; you can redistribute it and/or modify it |
405 | 405 | under the same terms as Perl itself. |
0 | # Copyrights 2007-2019 by [Mark Overmeer <markov@cpan.org>]. | |
0 | # Copyrights 2007-2021 by [Mark Overmeer <markov@cpan.org>]. | |
1 | 1 | # For other contributors see ChangeLog. |
2 | 2 | # See the manual pages for details on the licensing terms. |
3 | 3 | # Pod stripped from pm file by OODoc 2.02. |
7 | 7 | |
8 | 8 | package Log::Report::Domain; |
9 | 9 | use vars '$VERSION'; |
10 | $VERSION = '1.29'; | |
10 | $VERSION = '1.32'; | |
11 | 11 | |
12 | 12 | use base 'Log::Report::Minimal::Domain'; |
13 | 13 |
283 | 283 | |
284 | 284 | =head1 SEE ALSO |
285 | 285 | |
286 | This module is part of Log-Report distribution version 1.29, | |
287 | built on November 08, 2019. Website: F<http://perl.overmeer.net/CPAN/> | |
286 | This module is part of Log-Report distribution version 1.32, | |
287 | built on January 26, 2021. Website: F<http://perl.overmeer.net/CPAN/> | |
288 | 288 | |
289 | 289 | =head1 LICENSE |
290 | 290 | |
291 | Copyrights 2007-2019 by [Mark Overmeer <markov@cpan.org>]. For other contributors see ChangeLog. | |
291 | Copyrights 2007-2021 by [Mark Overmeer <markov@cpan.org>]. For other contributors see ChangeLog. | |
292 | 292 | |
293 | 293 | This program is free software; you can redistribute it and/or modify it |
294 | 294 | under the same terms as Perl itself. |
0 | # Copyrights 2007-2019 by [Mark Overmeer <markov@cpan.org>]. | |
0 | # Copyrights 2007-2021 by [Mark Overmeer <markov@cpan.org>]. | |
1 | 1 | # For other contributors see ChangeLog. |
2 | 2 | # See the manual pages for details on the licensing terms. |
3 | 3 | # Pod stripped from pm file by OODoc 2.02. |
7 | 7 | |
8 | 8 | package Log::Report::Exception; |
9 | 9 | use vars '$VERSION'; |
10 | $VERSION = '1.29'; | |
10 | $VERSION = '1.32'; | |
11 | 11 | |
12 | 12 | |
13 | 13 | use warnings; |
151 | 151 | |
152 | 152 | =head1 SEE ALSO |
153 | 153 | |
154 | This module is part of Log-Report distribution version 1.29, | |
155 | built on November 08, 2019. Website: F<http://perl.overmeer.net/CPAN/> | |
154 | This module is part of Log-Report distribution version 1.32, | |
155 | built on January 26, 2021. Website: F<http://perl.overmeer.net/CPAN/> | |
156 | 156 | |
157 | 157 | =head1 LICENSE |
158 | 158 | |
159 | Copyrights 2007-2019 by [Mark Overmeer <markov@cpan.org>]. For other contributors see ChangeLog. | |
159 | Copyrights 2007-2021 by [Mark Overmeer <markov@cpan.org>]. For other contributors see ChangeLog. | |
160 | 160 | |
161 | 161 | This program is free software; you can redistribute it and/or modify it |
162 | 162 | under the same terms as Perl itself. |
0 | # Copyrights 2007-2019 by [Mark Overmeer <markov@cpan.org>]. | |
0 | # Copyrights 2007-2021 by [Mark Overmeer <markov@cpan.org>]. | |
1 | 1 | # For other contributors see ChangeLog. |
2 | 2 | # See the manual pages for details on the licensing terms. |
3 | 3 | # Pod stripped from pm file by OODoc 2.02. |
7 | 7 | |
8 | 8 | package Log::Report::Message; |
9 | 9 | use vars '$VERSION'; |
10 | $VERSION = '1.29'; | |
10 | $VERSION = '1.32'; | |
11 | 11 | |
12 | 12 | |
13 | 13 | use warnings; |
552 | 552 | |
553 | 553 | =head1 SEE ALSO |
554 | 554 | |
555 | This module is part of Log-Report distribution version 1.29, | |
556 | built on November 08, 2019. Website: F<http://perl.overmeer.net/CPAN/> | |
555 | This module is part of Log-Report distribution version 1.32, | |
556 | built on January 26, 2021. Website: F<http://perl.overmeer.net/CPAN/> | |
557 | 557 | |
558 | 558 | =head1 LICENSE |
559 | 559 | |
560 | Copyrights 2007-2019 by [Mark Overmeer <markov@cpan.org>]. For other contributors see ChangeLog. | |
560 | Copyrights 2007-2021 by [Mark Overmeer <markov@cpan.org>]. For other contributors see ChangeLog. | |
561 | 561 | |
562 | 562 | This program is free software; you can redistribute it and/or modify it |
563 | 563 | under the same terms as Perl itself. |
0 | # Copyrights 2007-2019 by [Mark Overmeer <markov@cpan.org>]. | |
0 | # Copyrights 2007-2021 by [Mark Overmeer <markov@cpan.org>]. | |
1 | 1 | # For other contributors see ChangeLog. |
2 | 2 | # See the manual pages for details on the licensing terms. |
3 | 3 | # Pod stripped from pm file by OODoc 2.02. |
7 | 7 | |
8 | 8 | package Log::Report::Translator; |
9 | 9 | use vars '$VERSION'; |
10 | $VERSION = '1.29'; | |
10 | $VERSION = '1.32'; | |
11 | 11 | |
12 | 12 | |
13 | 13 | use warnings; |
65 | 65 | |
66 | 66 | =head1 SEE ALSO |
67 | 67 | |
68 | This module is part of Log-Report distribution version 1.29, | |
69 | built on November 08, 2019. Website: F<http://perl.overmeer.net/CPAN/> | |
68 | This module is part of Log-Report distribution version 1.32, | |
69 | built on January 26, 2021. Website: F<http://perl.overmeer.net/CPAN/> | |
70 | 70 | |
71 | 71 | =head1 LICENSE |
72 | 72 | |
73 | Copyrights 2007-2019 by [Mark Overmeer <markov@cpan.org>]. For other contributors see ChangeLog. | |
73 | Copyrights 2007-2021 by [Mark Overmeer <markov@cpan.org>]. For other contributors see ChangeLog. | |
74 | 74 | |
75 | 75 | This program is free software; you can redistribute it and/or modify it |
76 | 76 | under the same terms as Perl itself. |
0 | # Copyrights 2007-2019 by [Mark Overmeer <markov@cpan.org>]. | |
0 | # Copyrights 2007-2021 by [Mark Overmeer <markov@cpan.org>]. | |
1 | 1 | # For other contributors see ChangeLog. |
2 | 2 | # See the manual pages for details on the licensing terms. |
3 | 3 | # Pod stripped from pm file by OODoc 2.02. |
7 | 7 | |
8 | 8 | package Log::Report; |
9 | 9 | use vars '$VERSION'; |
10 | $VERSION = '1.29'; | |
10 | $VERSION = '1.32'; | |
11 | 11 | |
12 | 12 | use base 'Exporter'; |
13 | 13 | |
61 | 61 | |
62 | 62 | sub report($@) |
63 | 63 | { my $opts = ref $_[0] eq 'HASH' ? +{ %{ (shift) } } : {}; |
64 | my $reason = shift; | |
64 | my ($reason, $message) = (shift, shift); | |
65 | ||
65 | 66 | my $stop = exists $opts->{is_fatal} ? $opts->{is_fatal} : is_fatal $reason; |
67 | my $try = $nested_tries[-1]; # WARNING: overloaded boolean, use 'defined' | |
66 | 68 | |
67 | 69 | my @disp; |
68 | if(defined(my $try = $nested_tries[-1])) | |
70 | if(defined $try) | |
69 | 71 | { push @disp, @{$reporter->{needs}{$reason}||[]} |
70 | 72 | unless $stop || $try->hides($reason); |
71 | 73 | push @disp, $try if $try->needs($reason); |
81 | 83 | @disp || $stop |
82 | 84 | or return; |
83 | 85 | |
84 | $opts->{errno} ||= $!+0 || $? || 1 | |
85 | if use_errno($reason) && !defined $opts->{errno}; | |
86 | ||
87 | if(my $to = delete $opts->{to}) | |
86 | my $to = delete $opts->{to}; | |
87 | if($to) | |
88 | 88 | { # explicit destination, still disp may not need it. |
89 | 89 | if(ref $to eq 'ARRAY') |
90 | 90 | { my %disp = map +($_->name => $_), @disp; |
93 | 93 | else |
94 | 94 | { @disp = grep $_->name eq $to, @disp; |
95 | 95 | } |
96 | push @disp, $try if defined $try; | |
97 | ||
96 | 98 | @disp || $stop |
97 | 99 | or return; |
98 | 100 | } |
99 | 101 | |
100 | my $message = shift; | |
102 | $opts->{errno} ||= $!+0 || $? || 1 | |
103 | if use_errno($reason) && !defined $opts->{errno}; | |
101 | 104 | |
102 | 105 | unless(Log::Report::Dispatcher->can('collectLocation')) |
103 | 106 | { # internal Log::Report error can result in "deep recursions". |
127 | 130 | $message = $lrm->new(_prepend => $text, @_); |
128 | 131 | } |
129 | 132 | |
130 | if(my $to = $message->to) | |
131 | { @disp = grep $_->name eq $to, @disp; | |
133 | $message->to(undef) if $to; # overrule destination of message | |
134 | ||
135 | if(my $disp_name = $message->to) | |
136 | { @disp = grep $_->name eq $disp_name, @disp; | |
137 | push @disp, $try if defined $try && $disp_name ne 'try'; | |
132 | 138 | @disp or return; |
133 | 139 | } |
134 | 140 |
1158 | 1158 | |
1159 | 1159 | =head1 SEE ALSO |
1160 | 1160 | |
1161 | This module is part of Log-Report distribution version 1.29, | |
1162 | built on November 08, 2019. Website: F<http://perl.overmeer.net/CPAN/> | |
1161 | This module is part of Log-Report distribution version 1.32, | |
1162 | built on January 26, 2021. Website: F<http://perl.overmeer.net/CPAN/> | |
1163 | 1163 | |
1164 | 1164 | =head1 LICENSE |
1165 | 1165 | |
1166 | Copyrights 2007-2019 by [Mark Overmeer <markov@cpan.org>]. For other contributors see ChangeLog. | |
1166 | Copyrights 2007-2021 by [Mark Overmeer <markov@cpan.org>]. For other contributors see ChangeLog. | |
1167 | 1167 | |
1168 | 1168 | This program is free software; you can redistribute it and/or modify it |
1169 | 1169 | under the same terms as Perl itself. |
0 | # Copyrights 2007-2019 by [Mark Overmeer <markov@cpan.org>]. | |
0 | # Copyrights 2007-2021 by [Mark Overmeer <markov@cpan.org>]. | |
1 | 1 | # For other contributors see ChangeLog. |
2 | 2 | # See the manual pages for details on the licensing terms. |
3 | 3 | # Pod stripped from pm file by OODoc 2.02. |
7 | 7 | |
8 | 8 | package MojoX::Log::Report; |
9 | 9 | use vars '$VERSION'; |
10 | $VERSION = '1.29'; | |
10 | $VERSION = '1.32'; | |
11 | 11 | |
12 | 12 | use Mojo::Base 'Mojo::Log'; # implies use strict etc |
13 | 13 |
48 | 48 | |
49 | 49 | =head1 SEE ALSO |
50 | 50 | |
51 | This module is part of Log-Report distribution version 1.29, | |
52 | built on November 08, 2019. Website: F<http://perl.overmeer.net/CPAN/> | |
51 | This module is part of Log-Report distribution version 1.32, | |
52 | built on January 26, 2021. Website: F<http://perl.overmeer.net/CPAN/> | |
53 | 53 | |
54 | 54 | =head1 LICENSE |
55 | 55 | |
56 | Copyrights 2007-2019 by [Mark Overmeer <markov@cpan.org>]. For other contributors see ChangeLog. | |
56 | Copyrights 2007-2021 by [Mark Overmeer <markov@cpan.org>]. For other contributors see ChangeLog. | |
57 | 57 | |
58 | 58 | This program is free software; you can redistribute it and/or modify it |
59 | 59 | under the same terms as Perl itself. |
3 | 3 | use warnings; |
4 | 4 | use strict; |
5 | 5 | |
6 | use Test::More tests => 36; | |
6 | use Test::More; | |
7 | 7 | |
8 | 8 | use Log::Report undef, syntax => 'SHORT'; |
9 | 9 | use Carp; # required for tests |
114 | 114 | isa_ok($confess_ex, 'Log::Report::Exception'); |
115 | 115 | is($confess_ex->reason, 'PANIC'); |
116 | 116 | like("$@", qr[^try-block stopped with PANIC: oops3 at ] ); |
117 | ||
118 | done_testing; |
23 | 23 | $@ and plan skip_all => 'Unable to load HTTP::Request::Common'; |
24 | 24 | HTTP::Request::Common->import; |
25 | 25 | |
26 | plan tests => 3; | |
26 | plan tests => 4; | |
27 | 27 | } |
28 | 28 | |
29 | 29 | { |
39 | 39 | set logger => 'LogReport'; |
40 | 40 | |
41 | 41 | dispatcher close => 'default'; |
42 | ||
43 | hook before => sub { | |
44 | if (query_parameters->get('is_fatal')) | |
45 | { | |
46 | my $foo; | |
47 | $foo->bar; | |
48 | } | |
49 | }; | |
50 | ||
51 | # Unhandled exception in default route | |
52 | get '/' => sub { | |
53 | my $foo; | |
54 | $foo->bar; | |
55 | }; | |
42 | 56 | |
43 | 57 | get '/write_message/:level/:text' => sub { |
44 | 58 | my $level = param('level'); |
55 | 69 | |
56 | 70 | get '/process' => sub { |
57 | 71 | process(sub { error "Fatal error text" }); |
72 | }; | |
73 | ||
74 | get '/show_error/:show_error' => sub { | |
75 | set show_errors => route_parameters->get('show_error'); | |
58 | 76 | }; |
59 | 77 | |
60 | 78 | # Route to add custom handlers during later tests |
146 | 164 | } |
147 | 165 | }; |
148 | 166 | |
167 | # Tests to check unexpected exceptions | |
168 | subtest 'Unexpected exception default page' => sub { | |
169 | ||
170 | # An exception generated from the default route which cannot redirect to | |
171 | # the default route, so it throws a plain text error | |
172 | { | |
173 | my $req = GET "$url/"; | |
174 | my $res = $test->request( $req ); | |
175 | ok !$res->is_redirect, "No redirect for exception on default route"; | |
176 | is $res->content, "An unexpected error has occurred", "Plain text exception text correct"; | |
177 | } | |
178 | ||
179 | # The same as previous, but this time we enable the development setting | |
180 | # show_error, which means that the content returned is the actual Perl | |
181 | # error string | |
182 | { | |
183 | # First set show_error parameter | |
184 | $test->request(GET "$url/show_error/1"); | |
185 | my $req = GET "$url/"; | |
186 | my $res = $test->request( $req ); | |
187 | ok !$res->is_redirect, "get /write_message"; | |
188 | like $res->content, qr/Can't call method "bar" on an undefined value/; | |
189 | # Then set show_error back to disabled | |
190 | $test->request(GET "$url/show_error/0"); | |
191 | } | |
192 | ||
193 | # This time the exception occurs in an early hook and we are not able to do | |
194 | # anything as the request hasn't been populated yet. Therefore we should | |
195 | # expect Dancer's default error handling | |
196 | { | |
197 | my $req = GET "$url/?is_fatal=1"; | |
198 | my $res = $test->request( $req ); | |
199 | ok !$res->is_redirect, "get /write_message"; | |
200 | like $res->content, qr/Error 500 - Internal Server Error/; | |
201 | } | |
202 | }; | |
203 | ||
149 | 204 | # Tests to check custom fatal error handlers |
150 | 205 | subtest 'Custom handler' => sub { |
151 | 206 |
0 | # Copyrights 2007-2019 by [Mark Overmeer <markov@cpan.org>]. | |
0 | # Copyrights 2007-2021 by [Mark Overmeer <markov@cpan.org>]. | |
1 | 1 | # For other contributors see ChangeLog. |
2 | 2 | # See the manual pages for details on the licensing terms. |
3 | 3 | # Pod stripped from pm file by OODoc 2.02. |
4 | 4 | package DieTests; |
5 | 5 | use vars '$VERSION'; |
6 | $VERSION = '1.29'; | |
6 | $VERSION = '1.32'; | |
7 | 7 | |
8 | 8 | use warnings; |
9 | 9 | use strict; |