Initial Commit

This commit is contained in:
Riley Schneider
2025-12-03 16:38:10 +01:00
parent c5e26bf594
commit b732d8d4b5
17680 changed files with 5977495 additions and 2 deletions

View File

@@ -0,0 +1,44 @@
# Copyrights 2007-2021 by [Mark Overmeer <markov@cpan.org>].
# For other contributors see ChangeLog.
# See the manual pages for details on the licensing terms.
# Pod stripped from pm file by OODoc 2.02.
# This code is part of distribution Log-Report. Meta-POD processed with
# OODoc into POD and HTML manual-pages. See README.md
# Copyright Mark Overmeer. Licensed under the same terms as Perl itself.
package MojoX::Log::Report;
use vars '$VERSION';
$VERSION = '1.31';
use Mojo::Base 'Mojo::Log'; # implies use strict etc
use Log::Report 'log-report', import => 'report';
sub new(@) {
my $class = shift;
my $self = $class->SUPER::new(@_);
# issue with Mojo, where the base-class registers a function --not
# a method-- to handle the message.
$self->unsubscribe('message'); # clean all listeners
$self->on(message => '_message'); # call it OO
$self;
}
my %level2reason = qw/
debug TRACE
info INFO
warn WARNING
error ERROR
fatal ALERT
/;
sub _message($$@)
{ my ($self, $level) = (shift, shift);
report +{is_fatal => 0} # do not die on errors
, $level2reason{$level}, join('', @_);
}
1;

View File

@@ -0,0 +1,62 @@
=encoding utf8
=head1 NAME
MojoX::Log::Report - divert log messages into Log::Report
=head1 INHERITANCE
MojoX::Log::Report
is a Mojo::Log
=head1 SYNOPSIS
use MojoX::Log::Report;
my $log = MojoX::Log::Report->new(%options);
$app->log($log); # install logger in the Mojo::App
=head1 DESCRIPTION
[Included since Log::Report v1.00]
Mojo likes to log messages directly into a file, by default. Log::Report
constructs a L<Log::Report::Exception|Log::Report::Exception> object first.
Be aware that this extension does catch the messages to be logged,
but that the dispatching of the error follows a different route now.
For instance, you cannot use C<$ENV{MOJO_LOG_LEVEL}> to control the output
level, but you need to use L<Log::Report::dispatcher()|Log::Report/"Report Production and Configuration"> action C<mode>.
Mojo defines five "levels" of messages, which map onto Log::Report's
reasons this way:
debug TRACE
info INFO
warn WARNING
error ERROR
fatal ALERT
=head1 METHODS
=head2 Constructors
=over 4
=item MojoX::Log::Report-E<gt>B<new>(%options)
Inherited %options C<path> and C<level> are ignored.
=back
=head1 SEE ALSO
This module is part of Log-Report distribution version 1.31,
built on January 15, 2021. Website: F<http://perl.overmeer.net/CPAN/>
=head1 LICENSE
Copyrights 2007-2021 by [Mark Overmeer <markov@cpan.org>]. For other contributors see ChangeLog.
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
See F<http://dev.perl.org/licenses/>