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 aLog::Any::Adapterbefore you log your first log message. If you don't? Nothing happens. Literally nothing. Same energy as plainLog::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>
π₯ COPYRIGHT AND LICENSE π₯
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
- debian bookworm: libmoox-log-any-perl 0.004004-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libmoox-log-any-perl 0.004004-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