[libmoox-role-logger-perl] 02/08: initial import

Jonas Smedegaard dr at jones.dk
Mon Mar 23 20:24:29 UTC 2015


This is an automated email from the git hooks/post-receive script.

js pushed a commit to annotated tag release-0.001
in repository libmoox-role-logger-perl.

commit 144490bef0675a9bbb60823e8b20b106c3031c8d
Author: David Golden <dagolden at cpan.org>
Date:   Wed Oct 2 23:25:40 2013 -0400

    initial import
---
 .local.vimrc              |   1 +
 .perltidyrc               |  44 ++++++++++++++++++++
 CONTRIBUTING              |  50 +++++++++++++++++++++++
 Changes                   |   6 +++
 README.mkdn               |   1 +
 cpanfile                  |  28 +++++++++++++
 dist.ini                  |   9 +++++
 example/MyModule.pm       |  16 ++++++++
 example/app.pl            |  11 +++++
 lib/MooseX/Role/Logger.pm | 101 ++++++++++++++++++++++++++++++++++++++++++++++
 perlcritic.rc             |  23 +++++++++++
 tidyall.ini               |   5 +++
 12 files changed, 295 insertions(+)

diff --git a/.local.vimrc b/.local.vimrc
new file mode 100644
index 0000000..07e747d
--- /dev/null
+++ b/.local.vimrc
@@ -0,0 +1 @@
+autocmd BufWritePre *.pl,*.pm,*.t call DoTidyWrite()
diff --git a/.perltidyrc b/.perltidyrc
new file mode 100644
index 0000000..dfe7b7c
--- /dev/null
+++ b/.perltidyrc
@@ -0,0 +1,44 @@
+# DAGOLDEN .perltidyrc file
+
+-se     # Errors to STDERR
+
+-l=85   # Max line width target
+-vmll   # variable maximum line length
+-wc=10  # depth to reduce indentation levels
+-i=4    # Indent level
+-ci=2   # Continuation
+
+-vt=0   # vertical tightness
+-cti=0  # extra indentation for closing brackets
+-vtc=0  # close parens on own line if possible
+
+-nsot   # stack opening
+-nsct   # stack closing
+
+-notr    # opening tokens on right of a line
+-pt=1   # parenthesis tightness
+-bt=1   # brace tightness
+-sbt=1  # square bracket tightness
+-bbt=0  # block brace tightness
+#-boc    # break at old comma breakpoints
+-cab=1
+
+-nsfp   # no space after function
+-nsfs   # No space before semicolons in for loops
+
+-nolq   # Don't outdent long quoted strings
+-nola   # Don't outdent labels
+-nolc   # Don't outdent long comments
+-nokw   # Don't outdent keywords
+-nhsc   # Don't expect hanging side comments
+-nbbc   # No blank before comments
+-tso    # Tight secret operators
+
+-msc=1  # Space to side comment
+
+#-wbb="% + - * / x != == >= <= =~ !~ < > | & = **= += *= &= <<= &&= -= /= |= >>= ||= //= .= %= ^= x="
+-wbb="% + - * / x != == >= <= =~ !~ < > | &"
+        # Break before all operators except assignment
+
+-ole=unix # line endings
+
diff --git a/CONTRIBUTING b/CONTRIBUTING
new file mode 100644
index 0000000..aeb58e6
--- /dev/null
+++ b/CONTRIBUTING
@@ -0,0 +1,50 @@
+CONTRIBUTING
+
+Thank you for considering contributing to this distribution.  This file
+contains instructions that will help you work with the source code.
+
+The distribution is managed with Dist::Zilla.  This means than many of the
+usual files you might expect are not in the repository, but are generated
+at release time (e.g. Makefile.PL).
+
+However, you can run tests directly using the 'prove' tool:
+
+  $ prove -l
+  $ prove -lv t/some_test_file.t
+
+For most distributions, 'prove' is entirely sufficent for you to test any
+patches you have.
+
+You may need to satisfy some dependencies.  See the included META.json
+file for a list.  If you install App::mymeta_requires from CPAN, it's easy
+to satisfy any that you are missing by piping the output to your favorite
+CPAN client:
+
+  $ mymeta-requires | cpanm
+  $ cpan `mymeta-requires`
+
+Likewise, much of the documentation Pod is generated at release time.
+Depending on the distribution, some documentation may be written in a Pod
+dialect called WikiDoc. (See Pod::WikiDoc on CPAN.) If you would like to
+submit a documentation edit, please limit yourself to the documentation you
+see.
+
+If you see typos or documentation issues in the generated docs, please
+email or open a bug ticket instead of patching.
+
+Dist::Zilla is a very powerful authoring tool, but requires a number of
+author-specific plugins.  If you would like to use it for contributing,
+install it from CPAN, then run one of the following commands, depending on
+your CPAN client:
+
+  $ cpan `dzil authordeps`
+  $ dzil authordeps | cpanm
+
+Once installed, here are some dzil commands you might try:
+
+  $ dzil build
+  $ dzil test
+  $ dzil xtest
+
+You can learn more about Dist::Zilla at http://dzil.org/
+
diff --git a/Changes b/Changes
new file mode 100644
index 0000000..9865cb3
--- /dev/null
+++ b/Changes
@@ -0,0 +1,6 @@
+Revision history for MooseX-Role-Logger
+
+{{$NEXT}}
+
+    - First release
+
diff --git a/README.mkdn b/README.mkdn
new file mode 120000
index 0000000..73dfc33
--- /dev/null
+++ b/README.mkdn
@@ -0,0 +1 @@
+CONTRIBUTING
\ No newline at end of file
diff --git a/cpanfile b/cpanfile
new file mode 100644
index 0000000..53aa121
--- /dev/null
+++ b/cpanfile
@@ -0,0 +1,28 @@
+requires "Log::Any" => "0";
+requires "Moo::Role" => "0";
+requires "Types::Standard" => "0";
+requires "perl" => "v5.10.0";
+requires "strict" => "0";
+requires "warnings" => "0";
+
+on 'test' => sub {
+  requires "ExtUtils::MakeMaker" => "0";
+  requires "File::Spec" => "0";
+  requires "File::Spec::Functions" => "0";
+  requires "File::Temp" => "0";
+  requires "IO::Handle" => "0";
+  requires "IPC::Open3" => "0";
+  requires "List::Util" => "0";
+  requires "Test::More" => "0";
+};
+
+on 'configure' => sub {
+  requires "ExtUtils::MakeMaker" => "6.17";
+};
+
+on 'develop' => sub {
+  requires "Pod::Coverage::TrustPod" => "0";
+  requires "Test::CPAN::Meta" => "0";
+  requires "Test::Pod" => "1.41";
+  requires "Test::Pod::Coverage" => "1.08";
+};
diff --git a/dist.ini b/dist.ini
new file mode 100644
index 0000000..9da28ab
--- /dev/null
+++ b/dist.ini
@@ -0,0 +1,9 @@
+name    = MooseX-Role-Logger
+author  = David Golden <dagolden at cpan.org>
+license = Apache_2_0
+copyright_holder = David Golden
+copyright_year   = 2013
+
+[@DAGOLDEN]
+:version = 0.053
+
diff --git a/example/MyModule.pm b/example/MyModule.pm
new file mode 100644
index 0000000..f2ee790
--- /dev/null
+++ b/example/MyModule.pm
@@ -0,0 +1,16 @@
+use 5.008001;
+use strict;
+use warnings;
+
+package MyModule;
+
+use Moo;
+with 'MooseX::Role::Logger';
+
+sub cry {
+    my ($self) = @_;
+    $self->logger->info("I'm sad");
+}
+
+1;
+
diff --git a/example/app.pl b/example/app.pl
new file mode 100644
index 0000000..a8c2421
--- /dev/null
+++ b/example/app.pl
@@ -0,0 +1,11 @@
+use v5.10;
+use strict;
+use warnings;
+
+use MyModule;
+
+use Log::Any::Adapter ('Stdout');
+
+my $obj = MyModule->new;
+$obj->cry;
+
diff --git a/lib/MooseX/Role/Logger.pm b/lib/MooseX/Role/Logger.pm
new file mode 100644
index 0000000..46d9d21
--- /dev/null
+++ b/lib/MooseX/Role/Logger.pm
@@ -0,0 +1,101 @@
+use v5.10;
+use strict;
+use warnings;
+
+package MooseX::Role::Logger;
+# ABSTRACT: Provide logging via Log::Any
+# VERSION
+
+use Moo::Role;
+use Types::Standard qw/InstanceOf 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',
+    # Log::Any::Proxy will be in next-gen Log::Any and replace Log::Any::Adapter::*
+    isa =>
+      InstanceOf [qw/Log::Any::Proxy Log::Any::Adapter::Base Log::Any::Adapter::Null/],
+    init_arg => undef,
+);
+
+sub _build_logger {
+    my ($self) = @_;
+    return Log::Any->get_logger( category => $self->_category );
+}
+
+has _category => (
+    is  => 'lazy',
+    isa => Str,
+);
+
+=method _build__category
+
+Override to set the category used for logging.  Defaults to the class name of
+the object (which could be a subclass).
+
+=cut
+
+sub _build__category { return ref $_[0] }
+
+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 feeling 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.
+
+This role is based on L<Moo> so should work with either L<Moo> or L<Moose>
+based classes.
+
+=head1 SEE ALSO
+
+=for :list
+* L<MooseX::Role::Loggable>
+* L<MooseX::Role::LogHandler>
+* L<MooseX::Log::Log4perl>
+* L<MooseX::Log::Dispatch>
+
+=cut
+
+# vim: ts=4 sts=4 sw=4 et:
diff --git a/perlcritic.rc b/perlcritic.rc
new file mode 100644
index 0000000..cef05a8
--- /dev/null
+++ b/perlcritic.rc
@@ -0,0 +1,23 @@
+severity = 5
+verbose = 8
+
+[Variables::ProhibitPunctuationVars]
+allow = $@ $!
+
+[TestingAndDebugging::ProhibitNoStrict]
+allow = refs
+
+# Turn these off
+[-BuiltinFunctions::ProhibitStringyEval]
+[-ControlStructures::ProhibitPostfixControls]
+[-ControlStructures::ProhibitUnlessBlocks]
+[-Documentation::RequirePodSections]
+[-InputOutput::ProhibitInteractiveTest]
+[-References::ProhibitDoubleSigils]
+[-RegularExpressions::RequireExtendedFormatting]
+[-InputOutput::ProhibitTwoArgOpen]
+[-Modules::ProhibitEvilModules]
+
+# Turn this on
+[Lax::ProhibitStringyEval::ExceptForRequire]
+
diff --git a/tidyall.ini b/tidyall.ini
new file mode 100644
index 0000000..91aa246
--- /dev/null
+++ b/tidyall.ini
@@ -0,0 +1,5 @@
+; Install Code::TidyAll
+; run "tidyall -a" to tidy all files
+; run "tidyall -g" to tidy only files modified from git
+[PerlTidy]
+select = {lib,t}/**/*.{pl,pm,t}

-- 
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