Easy(3pm)

πŸ“¦
version 0.47 Β· 4 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– 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 🫢


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