MooX::Log::Any(3pm)

✨ MooX::Log::Any ✨

okay bestie, welcome to MooX::Log::Any πŸ’– β€” this is the Perl manual page for it, and yes it's a role, and yes it's giving extremely useful.


🌸 VERSION 🌸

version 0.004004 β€” she's on 0.004004, no cap.


πŸ’… DESCRIPTION πŸ’…

So like, this is a logging role that builds a very lightweight wrapper around Log::Any, made for your Moo or Moose classes. fr fr it's tiny.

🚨 IMPORTANT BESTIE: you gotta connect a Log::Any::Adapter before you log your first log message. If you don't? Nothing happens. Literally nothing. Same energy as plain Log::Any. So set it up first, okay? 🫢

Using the logger inside a class is genuinely as simple as consuming a role:

package MyClass;
use Moo;
with 'MooX::Log::Any';

sub dummy {
    my $self = shift;
    $self->log->info("Dummy log entry");
}

And the logger needs to be set up before you use it β€” which could totes happen in the main application:

package main;
use Log::Any::Adapter;
# Send all logs to Log::Log4perl
Log::Any::Adapter->set('Log4perl')

use MyClass;
my $myclass = MyClass->new();
$myclass->log->info("In my class"); # Access the log of the object
$myclass->dummy;                    # Will log "Dummy log entry"

slay. that's the whole vibe. πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

package MyApp;
use Moo;

with 'MooX::Log::Any';

sub something {
    my ($self) = @_;
    $self->log->debug("started bar");    ### logs with default class catergory "MyApp"
    $self->log->error("started bar");    ### logs with default class catergory "MyApp"
}

πŸ‘‘ ACCESSORS πŸ‘‘

🌈 log

The log attribute is holding the Log::Any::Adapter object, and that object is the one implementing all the logging methods for the defined log levels β€” think debug, think error. And because this method is also defined in other logging roles/systems like MooseX::Log::LogDispatch, you can lowkey think of it as a common logging interface. iconic behavior honestly.

package MyApp::View::JSON;

extends 'MyApp::View';
with 'MooseX:Log::Log4perl';

sub bar {
  $self->logger->info("Everything fine so far");    # logs a info message
  $self->logger->debug("Something is fishy here");  # logs a debug message
}

πŸŽ€ logger([$category])

This one is just an alias for log. that's it. that's the whole thing. πŸ’–


⭐ SEE ALSO ⭐

Log::Any, Moose, Moo β€” go read them, they're the friends of this module.

🧚 Inspired by

Inspired by the work by Chris Prather "<perigrin@cpan.org>" and Ash Berlin "<ash@cpan.org>" on MooseX::LogDispatch, and Roland Lammel "<lammel@cpan.org>". giving credit where credit is due, periodt. 🌸


πŸ’€ BUGS AND LIMITATIONS πŸ’€

Please report any bugs or feature requests through github <https://github.com/cazador481/MooX-Log-Any>. don't be shy, they wanna hear it 🫢


🌟 CONTRIBUTORS 🌟

In alphabetical order:

  • Jens Rehsack "rehsack@gmail.com>"

πŸ’œ AUTHOR πŸ’œ

Edward Ash <eddie+cpan@ashfamily.net>


This software is copyright (c) 2013 by Edward Ash.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.


okay that's the whole page bestie, you ate it πŸŽ€βœ¨ This was the MooX::Log::Any page, documented for perl v5.34.0 and dated 2022-06-16 β€” mwah, go log something cute πŸ’–πŸ¦‹

πŸ“¦ where this page comes from