| 1 | # This code is part of Perl distribution Log-Report version 1.46. | ||
| 2 | # The POD got stripped from this file by OODoc version 3.06. | ||
| 3 | # For contributors see file ChangeLog. | ||
| 4 | |||
| 5 | # This software is copyright (c) 2007-2026 by Mark Overmeer. | ||
| 6 | |||
| 7 | # This is free software; you can redistribute it and/or modify it under | ||
| 8 | # the same terms as the Perl 5 programming language system itself. | ||
| 9 | # SPDX-License-Identifier: Artistic-1.0-Perl OR GPL-1.0-or-later | ||
| 10 | |||
| 11 | |||
| 12 | package MojoX::Log::Report;{ | ||
| 13 | our $VERSION = '1.46'; | ||
| 14 | } | ||
| 15 | |||
| 16 | use Mojo::Base 'Mojo::Log'; # implies use strict etc | ||
| 17 | |||
| 18 | use Log::Report 'log-report', import => 'report'; | ||
| 19 | |||
| 20 | #-------------------- | ||
| 21 | |||
| 22 | sub new(@) { | ||
| 23 | my $class = shift; | ||
| 24 | my $self = $class->SUPER::new(@_); | ||
| 25 | |||
| 26 | # issue with Mojo, where the base-class registers a function --not | ||
| 27 | # a method-- to handle the message. | ||
| 28 | $self->unsubscribe('message'); # clean all listeners | ||
| 29 | $self->on(message => '_message'); # call it OO | ||
| 30 | $self; | ||
| 31 | } | ||
| 32 | |||
| 33 | my %level2reason = qw/ | ||
| 34 | debug TRACE | ||
| 35 | info INFO | ||
| 36 | warn WARNING | ||
| 37 | error ERROR | ||
| 38 | fatal ALERT | ||
| 39 | /; | ||
| 40 | |||
| 41 | sub _message($$@) | ||
| 42 | { my ($self, $level) = (shift, shift); | ||
| 43 | |||
| 44 | report +{is_fatal => 0}, # do not die on errors | ||
| 45 | $level2reason{$level}, join('', @_); | ||
| 46 | } | ||
| 47 | |||
| 48 | 1; |