Codebase list liblog-report-perl / ddc392e
New upstream version 1.33 gregor herrmann 2 years ago
47 changed file(s) with 99 addition(s) and 109 deletion(s). Raw diff Collapse all Expand all
55
66 TODO:
77 . connect to Message::Passing framework
8
9 version 1.33: Sat Jul 17 10:56:52 CEST 2021
10
11 Changes:
12 - the $@->died with always return the original die causing object or
13 string. In most cases, you want to use $@->wasFatal, which is the
14 translated (hence compatible) ::Exception object. [Andy Beverley]
815
916 version 1.32: Tue 26 Jan 09:13:31 CET 2021
1017
5353 "web" : "https://github.com/markov2/perl5-Log-Report"
5454 }
5555 },
56 "version" : "1.32",
56 "version" : "1.33",
5757 "x_serialization_backend" : "JSON::PP version 2.94"
5858 }
2828 homepage: http://perl.overmeer.net/CPAN/
2929 license: http://dev.perl.org/licenses/
3030 repository: https://github.com/markov2/perl5-Log-Report.git
31 version: '1.32'
31 version: '1.33'
3232 x_serialization_backend: 'CPAN::Meta::YAML version 0.011'
11
22 use 5.010;
33
4 my $version = '1.32';
4 my $version = '1.33';
55
66 my %prereq =
77 ( Test::More => '0.86'
77
88 package Dancer::Logger::LogReport;
99 use vars '$VERSION';
10 $VERSION = '1.32';
10 $VERSION = '1.33';
1111
1212 use base 'Dancer::Logger::Abstract', 'Exporter';
1313
6060
6161 =head1 SEE ALSO
6262
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/>
63 This module is part of Log-Report distribution version 1.33,
64 built on July 17, 2021. Website: F<http://perl.overmeer.net/CPAN/>
6565
6666 =head1 LICENSE
6767
77
88 package Dancer2::Logger::LogReport;
99 use vars '$VERSION';
10 $VERSION = '1.32';
10 $VERSION = '1.33';
1111
1212 # ABSTRACT: Dancer2 logger engine for Log::Report
1313
3737 sub BUILD
3838 { my $self = shift;
3939 my $configs = $self->dispatchers || {default => undef};
40 $self->{use} = [keys %$configs];
40 $self->{use} = [ keys %$configs ];
4141
4242 dispatcher 'do-not-reopen';
4343
7070
7171 =head1 SEE ALSO
7272
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/>
73 This module is part of Log-Report distribution version 1.33,
74 built on July 17, 2021. Website: F<http://perl.overmeer.net/CPAN/>
7575
7676 =head1 LICENSE
7777
77
88 package Dancer2::Plugin::LogReport::Message;
99 use vars '$VERSION';
10 $VERSION = '1.32';
10 $VERSION = '1.33';
1111
1212 use parent 'Log::Report::Message';
1313
7676
7777 =head1 SEE ALSO
7878
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/>
79 This module is part of Log-Report distribution version 1.33,
80 built on July 17, 2021. Website: F<http://perl.overmeer.net/CPAN/>
8181
8282 =head1 LICENSE
8383
77
88 package Dancer2::Plugin::LogReport;
99 use vars '$VERSION';
10 $VERSION = '1.32';
10 $VERSION = '1.33';
1111
1212
1313 use warnings;
512512
513513 =head1 SEE ALSO
514514
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/>
515 This module is part of Log-Report distribution version 1.33,
516 built on July 17, 2021. Website: F<http://perl.overmeer.net/CPAN/>
517517
518518 =head1 LICENSE
519519
77
88 package Log::Report::DBIC::Profiler;
99 use vars '$VERSION';
10 $VERSION = '1.32';
10 $VERSION = '1.33';
1111
1212 use base 'DBIx::Class::Storage::Statistics';
1313
3232
3333 =head1 SEE ALSO
3434
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/>
35 This module is part of Log-Report distribution version 1.33,
36 built on July 17, 2021. Website: F<http://perl.overmeer.net/CPAN/>
3737
3838 =head1 LICENSE
3939
77
88 package Log::Report::Die;
99 use vars '$VERSION';
10 $VERSION = '1.32';
10 $VERSION = '1.33';
1111
1212 use base 'Exporter';
1313
3030 my %opt = (errno => $! + 0);
3131 my $err = "$!";
3232
33 my $dietxt = $text[0];
3433 if($text[0] =~ s/ at (.+) line (\d+)\.?$// )
3534 { $opt{location} = [undef, $1, $2, undef];
3635 }
6059 : @stack ? 'PANIC'
6160 : $args{on_die} || 'ERROR';
6261
63 ($dietxt, \%opt, $reason, join("\n", @msg));
62 (\%opt, $reason, join("\n", @msg));
6463 }
6564
6665
9392 : @stack ? 'PANIC'
9493 : $on_die || 'ERROR';
9594
96 ('caught '.ref $exception, \%opts, $reason, $message);
95 (\%opts, $reason, $message);
9796 }
9897
9998 my %_libxml_errno2reason = (1 => 'WARNING', 2 => 'MISTAKE', 3 => 'ERROR');
111110 . ' (' . $exc->domain . ' error ' . $exc->code . ')';
112111
113112 my $reason = $_libxml_errno2reason{$exc->level} || 'PANIC';
114 ('caught '.ref $exc, \%opts, $reason, $msg);
113 (\%opts, $reason, $msg);
115114 }
116115
117116 sub exception_decode($%)
126125
127126 # Unsupported exception system, sane guesses
128127 my %opt =
129 ( classes => [ 'unknown exception', 'die', ref $exception ]
130 , errno => $errno
131 );
128 ( classes => [ 'unknown exception', 'die', ref $exception ]
129 , errno => $errno
130 );
132131
133132 my $reason = $errno ? 'FAULT' : $args{on_die} || 'ERROR';
134133
135134 # hopefully stringification is overloaded
136 ( "caught ".ref $exception, \%opt, $reason, "$exception");
135 (\%opt, $reason, "$exception");
137136 }
138137
139138 "to die or not to die, that's the question";
2929 parameters for L<Log::Report::report()|Log::Report/"Report Production and Configuration">. This is done in a very
3030 smart way, even trying to find the stringifications of C<$!>.
3131
32 Return are four elements: the error string which is used to trigger
33 a C<Log::Report> compatible C<die()>, and the options, reason, and
34 text message. The options is a HASH which, amongst other things,
35 may contain a stack trace and location.
32 Returned are four elements: the error string or object which triggered
33 the death originally (the original $@), and the opts, reason, and plain
34 text message. The opts is a HASH which, amongst other things, may contain
35 a stack trace and location extracted from the death text or object.
3636
3737 Translated components will have exception classes C<perl>, and C<die> or
3838 C<confess>. On the moment, the C<croak> cannot be distiguished from the
7777
7878 =head1 SEE ALSO
7979
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/>
80 This module is part of Log-Report distribution version 1.33,
81 built on July 17, 2021. Website: F<http://perl.overmeer.net/CPAN/>
8282
8383 =head1 LICENSE
8484
77
88 package Log::Report::Dispatcher::Callback;
99 use vars '$VERSION';
10 $VERSION = '1.32';
10 $VERSION = '1.33';
1111
1212 use base 'Log::Report::Dispatcher';
1313
173173
174174 =head1 SEE ALSO
175175
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/>
176 This module is part of Log-Report distribution version 1.33,
177 built on July 17, 2021. Website: F<http://perl.overmeer.net/CPAN/>
178178
179179 =head1 LICENSE
180180
77
88 package Log::Report::Dispatcher::File;
99 use vars '$VERSION';
10 $VERSION = '1.32';
10 $VERSION = '1.33';
1111
1212 use base 'Log::Report::Dispatcher';
1313
258258
259259 =head1 SEE ALSO
260260
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/>
261 This module is part of Log-Report distribution version 1.33,
262 built on July 17, 2021. Website: F<http://perl.overmeer.net/CPAN/>
263263
264264 =head1 LICENSE
265265
77
88 package Log::Report::Dispatcher::Log4perl;
99 use vars '$VERSION';
10 $VERSION = '1.32';
10 $VERSION = '1.33';
1111
1212 use base 'Log::Report::Dispatcher';
1313
229229
230230 =head1 SEE ALSO
231231
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/>
232 This module is part of Log-Report distribution version 1.33,
233 built on July 17, 2021. Website: F<http://perl.overmeer.net/CPAN/>
234234
235235 =head1 LICENSE
236236
77
88 package Log::Report::Dispatcher::LogDispatch;
99 use vars '$VERSION';
10 $VERSION = '1.32';
10 $VERSION = '1.33';
1111
1212 use base 'Log::Report::Dispatcher';
1313
193193
194194 =head1 SEE ALSO
195195
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/>
196 This module is part of Log-Report distribution version 1.33,
197 built on July 17, 2021. Website: F<http://perl.overmeer.net/CPAN/>
198198
199199 =head1 LICENSE
200200
77
88 package Log::Report::Dispatcher::Perl;
99 use vars '$VERSION';
10 $VERSION = '1.32';
10 $VERSION = '1.33';
1111
1212 use base 'Log::Report::Dispatcher';
1313
3838
3939 =head1 SEE ALSO
4040
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/>
41 This module is part of Log-Report distribution version 1.33,
42 built on July 17, 2021. Website: F<http://perl.overmeer.net/CPAN/>
4343
4444 =head1 LICENSE
4545
77
88 package Log::Report::Dispatcher::Syslog;
99 use vars '$VERSION';
10 $VERSION = '1.32';
10 $VERSION = '1.33';
1111
1212 use base 'Log::Report::Dispatcher';
1313
222222
223223 =head1 SEE ALSO
224224
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/>
225 This module is part of Log-Report distribution version 1.33,
226 built on July 17, 2021. Website: F<http://perl.overmeer.net/CPAN/>
227227
228228 =head1 LICENSE
229229
77
88 package Log::Report::Dispatcher::Try;
99 use vars '$VERSION';
10 $VERSION = '1.32';
10 $VERSION = '1.33';
1111
1212 use base 'Log::Report::Dispatcher';
1313
101101
102102 =item died => STRING
103103
104 The exit string ($@) of the eval'ed block.
104 The exit string or object ($@) of the eval'ed block, in its unprocessed state.
105105
106106 =item exceptions => ARRAY
107107
140140
141141 =item $obj-E<gt>B<died>( [STRING] )
142142
143 The message which was reported by C<eval>, which is used internally
144 to catch problems in the try block.
143 The exit string or object ($@) of the eval'ed block, in its unprocessed state.
144 They will always return true when they where deadly, and it always stringifies
145 into something useful.
145146
146147 =item $obj-E<gt>B<exceptions>()
147148
321322
322323 =head1 SEE ALSO
323324
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/>
325 This module is part of Log-Report distribution version 1.33,
326 built on July 17, 2021. Website: F<http://perl.overmeer.net/CPAN/>
326327
327328 =head1 LICENSE
328329
77
88 package Log::Report::Dispatcher;
99 use vars '$VERSION';
10 $VERSION = '1.32';
10 $VERSION = '1.33';
1111
1212
1313 use warnings;
394394
395395 =head1 SEE ALSO
396396
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/>
397 This module is part of Log-Report distribution version 1.33,
398 built on July 17, 2021. Website: F<http://perl.overmeer.net/CPAN/>
399399
400400 =head1 LICENSE
401401
77
88 package Log::Report::Domain;
99 use vars '$VERSION';
10 $VERSION = '1.32';
10 $VERSION = '1.33';
1111
1212 use base 'Log::Report::Minimal::Domain';
1313
283283
284284 =head1 SEE ALSO
285285
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/>
286 This module is part of Log-Report distribution version 1.33,
287 built on July 17, 2021. Website: F<http://perl.overmeer.net/CPAN/>
288288
289289 =head1 LICENSE
290290
77
88 package Log::Report::Exception;
99 use vars '$VERSION';
10 $VERSION = '1.32';
10 $VERSION = '1.33';
1111
1212
1313 use warnings;
151151
152152 =head1 SEE ALSO
153153
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/>
154 This module is part of Log-Report distribution version 1.33,
155 built on July 17, 2021. Website: F<http://perl.overmeer.net/CPAN/>
156156
157157 =head1 LICENSE
158158
77
88 package Log::Report::Message;
99 use vars '$VERSION';
10 $VERSION = '1.32';
10 $VERSION = '1.33';
1111
1212
1313 use warnings;
552552
553553 =head1 SEE ALSO
554554
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/>
555 This module is part of Log-Report distribution version 1.33,
556 built on July 17, 2021. Website: F<http://perl.overmeer.net/CPAN/>
557557
558558 =head1 LICENSE
559559
77
88 package Log::Report::Translator;
99 use vars '$VERSION';
10 $VERSION = '1.32';
10 $VERSION = '1.33';
1111
1212
1313 use warnings;
6565
6666 =head1 SEE ALSO
6767
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/>
68 This module is part of Log-Report distribution version 1.33,
69 built on July 17, 2021. Website: F<http://perl.overmeer.net/CPAN/>
7070
7171 =head1 LICENSE
7272
77
88 package Log::Report;
99 use vars '$VERSION';
10 $VERSION = '1.32';
10 $VERSION = '1.33';
1111
1212 use base 'Exporter';
1313
313313 my $is_exception = blessed $err && $err->isa('Log::Report::Exception');
314314 if(!$is_exception && $err && !$disp->wasFatal)
315315 { # Decode exceptions which do not origin from Log::Report reports
316 ($err, my($opts, $reason, $text)) = blessed $err
316 my($opts, $reason, $text) = blessed $err
317317 ? Log::Report::Die::exception_decode($err)
318318 : Log::Report::Die::die_decode($err, on_die => $disp->die2reason);
319319
11581158
11591159 =head1 SEE ALSO
11601160
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/>
1161 This module is part of Log-Report distribution version 1.33,
1162 built on July 17, 2021. Website: F<http://perl.overmeer.net/CPAN/>
11631163
11641164 =head1 LICENSE
11651165
77
88 package MojoX::Log::Report;
99 use vars '$VERSION';
10 $VERSION = '1.32';
10 $VERSION = '1.33';
1111
1212 use Mojo::Base 'Mojo::Log'; # implies use strict etc
1313
4848
4949 =head1 SEE ALSO
5050
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/>
51 This module is part of Log-Report distribution version 1.33,
52 built on July 17, 2021. Website: F<http://perl.overmeer.net/CPAN/>
5353
5454 =head1 LICENSE
5555
2424 __WITHOUT_STACKTRACE
2525
2626 is_deeply [ exception_decode(exception $dbix1) ]
27 , [ 'caught DBIx::Class::Exception'
28 , { location => [ $0, '/tmp/a.pl', '6', undef ] }
27 , [ { location => [ $0, '/tmp/a.pl', '6', undef ] }
2928 , 'ERROR'
3029 , 'help'
3130 ], 'set 1';
3736 __WITH_STACKTRACE
3837
3938 is_deeply [ exception_decode(exception $dbix2) ]
40 , [ 'caught DBIx::Class::Exception'
41 , { location => [ 'main', '/tmp/a.pl', '6', 'f' ]
39 , [ { location => [ 'main', '/tmp/a.pl', '6', 'f' ]
4240 , stack => [ [ 'main::f', '/tmp/a.pl', '8' ]
4341 , [ 'main::g', '/tmp/a.pl', '10' ]
4442 ]
5250 __WITHOUT_STACKTRACE
5351
5452 is_deeply [ exception_decode(exception $dbix3) ]
55 , [ 'caught DBIx::Class::Exception'
56 , { location => [ $0, '/tmp/a.pl', '6', undef ] }
53 , [ { location => [ $0, '/tmp/a.pl', '6', undef ] }
5754 , 'ERROR'
5855 , 'help'
5956 ], 'set 3';
6562 #warn "DBIx4:", Dumper exception_decode(exception $dbix4);
6663
6764 is_deeply [ exception_decode(exception $dbix4) ]
68 , [ 'caught DBIx::Class::Exception'
69 , { location =>
65 , [ { location =>
7066 [ 'DBIx::Class::Storage::DBI'
7167 , '/home/abeverley/git/Isaas/bin/../lib/Isaas/DBIC.pm'
7268 , '18'
2929 my $msg = pop @dec;
3030
3131 # error code changed from libxml2 2.9.9 to 2.9.10
32 my $rc = delete $dec[1]{errno};
33 $dec[1]{errno} = 'RC';
32 my $rc = delete $dec[0]{errno};
33 $dec[0]{errno} = 'RC';
3434 cmp_ok $rc, '>', 13000, 'error code';
3535
3636 is_deeply \@dec,
37 , [ 'caught XML::LibXML::Error'
38 , { location => [ 'libxml', '', '1', 'parser' ], errno => 'RC' }
37 , [ { location => [ 'libxml', '', '1', 'parser' ], errno => 'RC' }
3938 , 'ERROR'
4039 ], 'error 1';
4140
33 # Pod stripped from pm file by OODoc 2.02.
44 package DieTests;
55 use vars '$VERSION';
6 $VERSION = '1.32';
6 $VERSION = '1.33';
77
88 use warnings;
99 use strict;
2828 my $errstr = "$!";
2929
3030 sub process($)
31 {
32 my ($err, $opt, $reason, $message) = die_decode shift;
33 $err =~ s/\d+\.?$/XX/;
31 { my $err = shift;
32 my ($opt, $reason, $message) = die_decode $err;
33 # $err =~ s/\d+\.?$/XX/;
3434 my $errno = $opt->{errno} || 'no errno';
3535 my $loc = $opt->{location};
3636 my $loca = $loc ? "$loc->[1]#XX" : 'no location';
3737 my $stack = join "\n",
3838 map { join '#', $_->[0], $_->[1], 'XX' }
3939 @{$opt->{stack}};
40
4041 my $r = <<__RESULT;
4142 $reason: $message ($errno)
42 $err
4343 $loca
4444 $stack
4545 __RESULT
6262 my $die_text1 = $@;
6363 is(process($die_text1), <<__OUT, "die");
6464 ERROR: ouch (no errno)
65 ouch at t/DieTests.pm line XX
6665 t/DieTests.pm#XX
6766
6867 __OUT
7170 my $die_text2 = $@;
7271 is(process($die_text2), <<__OUT, "die");
7372 ERROR: ouch (no errno)
74 ouch
7573 no location
7674
7775 __OUT
8078 my $die_text3 = $@;
8179 is(process($die_text3), <<__OUT, "die");
8280 FAULT: ouch (3)
83 ouch No such process at t/DieTests.pm line XX
8481 t/DieTests.pm#XX
8582
8683 __OUT
8986 my $die_text4 = $@;
9087 is(process($die_text4), <<__OUT, "die");
9188 FAULT: ouch (3)
92 ouch No such process
9389 no location
9490
9591 __OUT
10096 my $croak_text1 = $@;
10197 is(process($croak_text1), <<__OUT, "croak");
10298 ERROR: ouch (no errno)
103 ouch at t/41die.t line XX
10499 t/41die.t#XX
105100
106101 __OUT
109104 my $croak_text2 = $@;
110105 is(process($croak_text2), <<__OUT, "croak");
111106 ERROR: ouch (no errno)
112 ouch
113107 t/41die.t#XX
114108
115109 __OUT
118112 my $croak_text3 = $@;
119113 is(process($croak_text3), <<__OUT, "croak");
120114 FAULT: ouch (3)
121 ouch No such process at t/41die.t line XX
122115 t/41die.t#XX
123116
124117 __OUT
127120 my $croak_text4 = $@;
128121 is(process($croak_text4), <<__OUT, "croak");
129122 FAULT: ouch (3)
130 ouch No such process
131123 t/41die.t#XX
132124
133125 __OUT
138130 my $confess_text1 = $@;
139131 is(process($confess_text1), <<__OUT, "confess");
140132 PANIC: ouch (no errno)
141 ouch at t/DieTests.pm line XX
142133 t/DieTests.pm#XX
143134 eval {...}#t/DieTests.pm#XX
144135 DieTests::run_tests()#t/41die.t#XX
149140 my $confess_text2 = $@;
150141 is(process($confess_text2), <<__OUT, "confess");
151142 PANIC: ouch (no errno)
152 ouch
153143 t/DieTests.pm#XX
154144 eval {...}#t/DieTests.pm#XX
155145 DieTests::run_tests()#t/41die.t#XX
160150 my $confess_text3 = $@;
161151 is(process($confess_text3), <<__OUT, "confess");
162152 FAULT: ouch (3)
163 ouch No such process at t/DieTests.pm line XX
164153 t/DieTests.pm#XX
165154 eval {...}#t/DieTests.pm#XX
166155 DieTests::run_tests()#t/41die.t#XX
179168 my $confess_text4 = $@;
180169 is(process($confess_text4), <<__OUT, "confess");
181170 FAULT: ouch (3)
182 ouch No such process
183171 t/DieTests.pm#XX
184172 eval {...}#t/DieTests.pm#XX
185173 DieTests::run_tests()#t/41die.t#XX