MooseX:...Dispatch(3)
π NAME π
MooseX::LazyLogDispatch β a Logging Role for Moose, bestie. it's giving "your Moose class but with a whole logging glow-up" β¨
πΈ VERSION πΈ
This doc is describing MooseX::LazyLogDispatch version 0.01, okay? oldie but a goodie π
π SYNOPSIS π
okay so here's the whole vibe, look:
package MyApp;
use Moose;
with MooseX::LazyLogDispatch;
# or alternately, use this role instead to give your
# class the logger methods "debug", "warning", etc...
# with MooseX::LazyLogDispatch::Levels;
# This part optional
# without it you get some default logging to the screen
has log_dispatch_conf => (
is => 'ro',
isa => 'Log::Dispatch::Configurator',
lazy => 1,
required => 1,
default => sub {
my $self = shift;
My::Configurator->new( # <- you write this class!
file => $self->log_file,
debug => $self->debug,
);
},
);
# Here's another variant, using a Log::Dispatch::Configurator-style
# hashref to configure things without an explicit subclass
has log_dispatch_conf => (
is => 'ro',
isa => 'HashRef',
lazy => 1,
required => 1,
default => sub {
my $self = shift;
return $self->debug
? {
class => 'Log::Dispatch::Screen',
min_level => 'debug',
stderr => 1,
format => '[%p] %m at %F line %L%n',
}
: {
class => 'Log::Dispatch::Syslog',
min_level => 'info',
facility => 'daemon',
ident => $self->daemon_name,
format => '[%p] %m',
};
},
);
sub foo {
my ($self) = @_;
$self->logger->debug("started foo");
....
$self->logger->debug('ending foo');
}
like, that's it. that's the whole thing. slay π₯
π¦ DESCRIPTION π¦
It's a Log::Dispatch role, and you just... with it into your Moose classes. that's the whole pitch, no cap π«Ά
β¨ INTERFACE β¨
π logger
This method comes free with the role, and it hands you back a Log::Dispatch instance. you can call level-names on it directly β exactly like those debug examples up in the synopsis. iykyk π
ngl tho, if you want the level-names to just be methods on your own class? use the MooseX::LazyLogDispatch::Levels role instead. main character energy, no middleman π
π log_dispatch_config
This is an optional attribute you can give your class, and it's lowkey the whole personality of this module. If you define it as a hashref value, that gets interpreted in the style of the configuration hashrefs documented over in the Log::Dispatch::Config docs β y'know, the ones where they show examples of using Log::Dispatch::Configurator for pluggable configuration. π§
You can also go full extra and gain greater flexibility by defining your own complete Log::Dispatch::Configurator subclass, and then having your "log_dispatch_config" attribute be an instance of that class. obsessed π
By lazy-loading either one (lazy = 1>), you can have the configuration determined at runtime. which is SO nice if you wanna switch up your log format and/or destination at runtime, based on stuff like MooseX::Getopt / MooseX::Daemonize parameters. periodt β¨
And if you just... don't provide this attribute at all? no stress, bestie β we'll default to sending everything to the screen in a reasonable debugging format. π
π SEE ALSO π
MooseX::LazyLogDispatch::LevelsMooseX::LogDispatchLog::Dispatch::ConfiguratorLog::Dispatch::ConfigLog::Dispatch
π AUTHOR π
Brandon Black "<blblack@gmail.com>" π«
Based in part on MooseX::LogDispatch by Ash Berlin "<ash@cpan.org>" and "<perigrin@cpan.org>" β shoutout to the OGs π«Ά
π LICENCE π
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic. π
and that's a wrap!! this page came to you from the User Contributed Perl Documentation corner of the world, titled MooseX:...Dispatch(3), and it was rendered up all pretty by perl v5.42.0 back on 2025-07-25 π go forth and log, bestie πβ¨
π¦ where this page comes from
- fedora 43: perl-MooseX-LazyLogDispatch 0.02-48.fc43 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms