Easy(3pm)
π Easy(3pm) β MooseX::Log::Log4perl::Easy π
okay so bestie, this is Easy(3pm), aka the manual page for MooseX::Log::Log4perl::Easy β a role for easy usage of logging in your Moose based modules based on MooseX::Log::Log4perl. yes the name is a whole mouthful, we know, but the vibe is genuinely immaculate. π
β¨ NAME β¨
MooseX::Log::Log4perl::Easy β a role for easy usage of logging in your Moose based modules based on MooseX::Log::Log4perl. it's giving "logging but make it effortless". π
πΈ SYNOPSIS πΈ
like, here's the whole entire vibe:
package MyApp;
use Moose;
use Log::Log4perl qw(:easy);
with 'MooseX::Log::Log4perl::Easy';
BEGIN {
Log::Log4perl->easy_init();
}
sub foo {
my ($self) = @_;
$self->log_debug("started bar"); ### logs with default class catergory "MyApp"
$self->log_info('bar'); ### logs an info message
$self->log('AlsoPossible')->fatal("croak"); ### log
}
see how clean that is?? no cap. π¦
π DESCRIPTION π
so the Easy logging role is based on the MooseX::Log::Log4perl logging role, but for Moose it goes ahead and directly adds the log methods for all available levels to your class instance. meaning you can literally just do
$self->log_info("blabla");
without having to access a separate log attribute like you'd have to in MooseX::Log::Log4perl. iconic behavior honestly. β¨
and listen β when your app grows up and you need more of the super-cow powers of Log4perl ππ¦Έ, or you simply don't want the additional methods to clutter up your class, you can just swap out all the code $self->log_LEVEL with $self->log->LEVEL. easy peasy. no drama.
you can use the following regex substitution to accomplish that:
s/log(_(trace|debug|info|warn|error|fatal))/log->$2/g
one line. ate. π
π ACCESSORS π
logger
see MooseX::Log::Log4perl. π
log
see MooseX::Log::Log4perl. π
log_fatal ($msg)
logs a fatal message $msg using the logger attribute. same as calling
$self->logger->fatal($msg)
log_error ($msg)
logs an error message using the logger attribute. same as calling
$self->logger->error($msg)
log_warn ($msg)
logs a warn message using the logger attribute. same as calling
$self->logger->warn($msg)
log_info ($msg)
logs an info message using the logger attribute. same as calling
$self->logger->info($msg)
log_debug ($msg)
logs a debug message using the logger attribute. same as calling
$self->logger->debug($msg)
log_trace ($msg)
logs a trace message using the logger attribute. same as calling
$self->logger->trace($msg)
six levels, six methods, zero excuses not to log your life. π
π¦ SEE ALSO π¦
- MooseX::Log::Log4perl
π AUTHOR π
Roland Lammel "<lammel@cpan.org>" β ty king π«Ά
π LICENSE AND COPYRIGHT π
Copyright (c) 2008-2016, Roland Lammel <lammel@cpan.org>, http://www.quikit.at
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.
fr fr, it's free software under the same terms as Perl itself. go wild, bestie. π
and that's the whole page, babe π β this was perl v5.34.0, dated 2022-06-15, and it ate every single time. πβ¨πΈ
π¦ where this page comes from
- debian bookworm: libmoosex-log-log4perl-perl 0.47-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libmoosex-log-log4perl-perl 0.47-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libmoosex-log-log4perl-perl 0.47-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libmoosex-log-log4perl-perl 0.47-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libmoosex-log-log4perl-perl 0.47-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms