[libmoox-role-logger-perl] 02/03: rename to MooX::Role::Logger and deprecate MooseX::Role::Logger
Jonas Smedegaard
dr at jones.dk
Mon Mar 23 20:24:31 UTC 2015
This is an automated email from the git hooks/post-receive script.
js pushed a commit to annotated tag release-0.004
in repository libmoox-role-logger-perl.
commit 465d22e4ccdaf12ef315c18118e2c3e01c8ce975
Author: David Golden <dagolden at cpan.org>
Date: Thu Sep 18 10:07:25 2014 -0400
rename to MooX::Role::Logger and deprecate MooseX::Role::Logger
---
.gitignore | 2 +-
Changes | 10 ++-
cpanfile | 9 +--
dist.ini | 4 +-
lib/{MooseX => MooX}/Role/Logger.pm | 8 +-
lib/MooseX/Role/Logger.pm | 145 ++----------------------------------
t/lib/MyModule2.pm | 20 +++++
t/{basic.t => moosex.t} | 0
t/{basic.t => moox.t} | 4 +-
9 files changed, 47 insertions(+), 155 deletions(-)
diff --git a/.gitignore b/.gitignore
index fe39f7c..7f7ba93 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,3 @@
-/MooseX-Role-Logger*
+/MooX-Role-Logger*
/.build
/.tidyall.d
diff --git a/Changes b/Changes
index 89019f9..273a4c5 100644
--- a/Changes
+++ b/Changes
@@ -1,7 +1,15 @@
-Revision history for MooseX-Role-Logger
+Revision history for MooX-Role-Logger
{{$NEXT}}
+ [Changed]
+
+ - Renamed to MooX::Role::Logger for clarify that it works with Moo or
+ Moose.
+
+ - MooseX::Role::Logger deprecated but kept as a wrapper for backwards
+ compatibility.
+
0.003 2014-07-03 12:38:11-04:00 America/New_York
[Changed]
diff --git a/cpanfile b/cpanfile
index a461935..c9d39ef 100644
--- a/cpanfile
+++ b/cpanfile
@@ -7,19 +7,16 @@ requires "warnings" => "0";
on 'test' => sub {
requires "ExtUtils::MakeMaker" => "0";
- requires "File::Spec::Functions" => "0";
- requires "List::Util" => "0";
+ requires "File::Spec" => "0";
requires "Log::Any::Test" => "0";
requires "Moo" => "0";
requires "Test::FailWarnings" => "0";
requires "Test::More" => "0.96";
requires "lib" => "0";
- requires "version" => "0";
};
on 'test' => sub {
- recommends "CPAN::Meta" => "0";
- recommends "CPAN::Meta::Requirements" => "2.120900";
+ recommends "CPAN::Meta" => "2.120900";
};
on 'configure' => sub {
@@ -28,7 +25,7 @@ on 'configure' => sub {
on 'develop' => sub {
requires "Dist::Zilla" => "5";
- requires "Dist::Zilla::PluginBundle::DAGOLDEN" => "0.053";
+ requires "Dist::Zilla::PluginBundle::DAGOLDEN" => "0.060";
requires "File::Spec" => "0";
requires "File::Temp" => "0";
requires "IO::Handle" => "0";
diff --git a/dist.ini b/dist.ini
index 9da28ab..17e395b 100644
--- a/dist.ini
+++ b/dist.ini
@@ -1,9 +1,9 @@
-name = MooseX-Role-Logger
+name = MooX-Role-Logger
author = David Golden <dagolden at cpan.org>
license = Apache_2_0
copyright_holder = David Golden
copyright_year = 2013
[@DAGOLDEN]
-:version = 0.053
+:version = 0.060
diff --git a/lib/MooseX/Role/Logger.pm b/lib/MooX/Role/Logger.pm
similarity index 95%
copy from lib/MooseX/Role/Logger.pm
copy to lib/MooX/Role/Logger.pm
index 0fe17c0..ec586ea 100644
--- a/lib/MooseX/Role/Logger.pm
+++ b/lib/MooX/Role/Logger.pm
@@ -1,7 +1,7 @@
use strict;
use warnings;
-package MooseX::Role::Logger;
+package MooX::Role::Logger;
# ABSTRACT: Provide logging via Log::Any
# VERSION
@@ -52,7 +52,7 @@ In your modules:
package MyModule;
use Moose;
- with 'MooseX::Role::Logger';
+ with 'MooX::Role::Logger';
sub run {
my ($self) = @_;
@@ -116,7 +116,7 @@ create your own role and set the C<_build__logger_category> there:
package MyLibrary::Role::Logger;
use Moo::Role;
- with 'MooseX::Role::Logger';
+ with 'MooX::Role::Logger';
sub _build__logger_category { "MyLibrary" }
@@ -128,7 +128,7 @@ Then in your other classes, use your custom role:
=head1 SEE ALSO
-Since MooseX::Role::Logger is universal, you have to use it with one of
+Since MooX::Role::Logger is universal, you have to use it with one of
several L<Log::Any::Adapter> classes:
=for :list
diff --git a/lib/MooseX/Role/Logger.pm b/lib/MooseX/Role/Logger.pm
index 0fe17c0..30ef199 100644
--- a/lib/MooseX/Role/Logger.pm
+++ b/lib/MooseX/Role/Logger.pm
@@ -2,154 +2,21 @@ use strict;
use warnings;
package MooseX::Role::Logger;
-# ABSTRACT: Provide logging via Log::Any
+# ABSTRACT: Provide logging via Log::Any (DEPRECATED)
# VERSION
use Moo::Role;
-use Types::Standard qw/Str/;
-
-use Log::Any ();
-
-=method _logger
-
-Returns a logging object. See L<Log::Any> for a list of logging methods it accepts.
-
-=cut
-
-has _logger => (
- is => 'lazy',
- isa => sub { ref( $_[0] ) =~ /^Log::Any/ }, # XXX too many options
- init_arg => undef,
-);
-
-sub _build__logger {
- my ($self) = @_;
- return Log::Any->get_logger( category => $self->_logger_category );
-}
-
-has _logger_category => (
- is => 'lazy',
- isa => Str,
-);
-
-=method _build__logger_category
-
-Override to set the category used for logging. Defaults to the class name of
-the object (which could be a subclass). You can override to lock it to a
-particular name:
-
- sub _build__logger_category { __PACKAGE__ }
-
-=cut
-
-sub _build__logger_category { return ref $_[0] }
+with 'MooX::Role::Logger';
1;
-=head1 SYNOPSIS
-
-In your modules:
-
- package MyModule;
- use Moose;
- with 'MooseX::Role::Logger';
-
- sub run {
- my ($self) = @_;
- $self->cry;
- }
-
- sub cry {
- my ($self) = @_;
- $self->_logger->info("I'm sad");
- }
-
-In your application:
-
- use MyModule;
- use Log::Any::Adapter ('File', '/path/to/file.log');
-
- MyModule->run;
-
=head1 DESCRIPTION
-This role provides universal logging via L<Log::Any>. The class using this
-role doesn't need to know or care about the details of log configuration,
-implementation or destination.
-
-Use it when you want your module to offer logging capabilities, but don't know
-who is going to use your module or what kind of logging they will implement.
-This role lets you do your part and leaves actual log setup and routing to
-someone else.
-
-The application that ultimately uses your module can then choose to direct log
-messages somewhere based on its own needs and configuration with
-L<Log::Any::Adapter>.
-
-This role is based on L<Moo> so it should work with either L<Moo> or L<Moose>
-based classes.
-
-=head1 USAGE
-
-=head2 Testing
-
-Testing with L<Log::Any> is pretty easy, thanks to L<Log::Any::Test>.
-Just load that before L<Log::Any> loads and your log messages get
-sent to a test adapter that includes testing methods:
-
- use Test::More 0.96;
- use Log::Any::Test;
- use Log::Any qw/$log/;
-
- use lib 't/lib';
- use MyModule;
-
- MyModule->new->cry;
- $log->contains_ok( qr/I'm sad/, "got log message" );
-
- done_testing;
-
-=head2 Customizing
-
-If you have a whole set of classes that should log with a single category,
-create your own role and set the C<_build__logger_category> there:
-
- package MyLibrary::Role::Logger;
- use Moo::Role;
- with 'MooseX::Role::Logger';
-
- sub _build__logger_category { "MyLibrary" }
-
-Then in your other classes, use your custom role:
-
- package MyLibrary::Foo;
- use Moo;
- with 'MyLibrary::Role::Logger'
-
-=head1 SEE ALSO
-
-Since MooseX::Role::Logger is universal, you have to use it with one of
-several L<Log::Any::Adapter> classes:
-
-=for :list
-* L<Log::Any::Adapter::File>
-* L<Log::Any::Adapter::Stderr>
-* L<Log::Any::Adapter::Stdout>
-* L<Log::Any::Adapter::ScreenColoredLevel>
-* L<Log::Any::Adapter::Dispatch>
-* L<Log::Any::Adapter::Syslog>
-* L<Log::Any::Adapter::Log4perl>
-
-These other logging roles are specific to particular logging packages, rather
-than being universal:
+L<MooseX::Role::Logger> has been renamed to L<MooX::Role::Logger> to clarify
+that it works with both L<Moo> and L<Moose>. This role just wraps that one and
+is provided for backwards compatibility.
-=for :list
-* L<MooseX::LazyLogDispatch>
-* L<MooseX::Log::Log4perl>
-* L<MooseX::LogDispatch>
-* L<MooseX::Role::LogHandler>
-* L<MooseX::Role::Loggable> (uses L<Log::Dispatchouli>)
-* L<Role::Log::Syslog::Fast>
+See L<MooX::Role::Logger> for usage details.
=cut
diff --git a/t/lib/MyModule2.pm b/t/lib/MyModule2.pm
new file mode 100644
index 0000000..88f11de
--- /dev/null
+++ b/t/lib/MyModule2.pm
@@ -0,0 +1,20 @@
+use strict;
+use warnings;
+
+package MyModule2;
+
+use Moo;
+with 'MooX::Role::Logger';
+
+sub run {
+ my ($self) = @_;
+ $self->cry;
+}
+
+sub cry {
+ my ($self) = @_;
+ $self->_logger->info("I'm sad");
+}
+
+1;
+
diff --git a/t/basic.t b/t/moosex.t
similarity index 100%
copy from t/basic.t
copy to t/moosex.t
diff --git a/t/basic.t b/t/moox.t
similarity index 88%
rename from t/basic.t
rename to t/moox.t
index 2f3c915..39330c5 100644
--- a/t/basic.t
+++ b/t/moox.t
@@ -8,9 +8,9 @@ use Log::Any qw/$log/;
use lib 't/lib';
-use MyModule;
+use MyModule2;
-my $obj = new_ok('MyModule');
+my $obj = new_ok('MyModule2');
my $log_class = ref $obj->_logger;
like( $log_class, qr/^Log::Any/, "logger came is from Log::Any" );
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libmoox-role-logger-perl.git
More information about the Pkg-perl-cvs-commits
mailing list