diff options
author | Angelo Naselli <anaselli@linux.it> | 2015-12-28 17:52:20 +0100 |
---|---|---|
committer | Angelo Naselli <anaselli@linux.it> | 2015-12-28 17:52:20 +0100 |
commit | 3a9e28aee7977f7b9455d34fec952f2af3776bbf (patch) | |
tree | 79791de570b1a04a5a8db35af14c6510c79d580a /lib | |
parent | 99b2c73ba993a59be7abb2c1e671fb297244ad97 (diff) | |
download | manatools-3a9e28aee7977f7b9455d34fec952f2af3776bbf.tar manatools-3a9e28aee7977f7b9455d34fec952f2af3776bbf.tar.gz manatools-3a9e28aee7977f7b9455d34fec952f2af3776bbf.tar.bz2 manatools-3a9e28aee7977f7b9455d34fec952f2af3776bbf.tar.xz manatools-3a9e28aee7977f7b9455d34fec952f2af3776bbf.zip |
Added Logging role
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ManaTools/ConfigDirRole.pm | 2 | ||||
-rw-r--r-- | lib/ManaTools/LoggingRole.pm | 98 |
2 files changed, 100 insertions, 0 deletions
diff --git a/lib/ManaTools/ConfigDirRole.pm b/lib/ManaTools/ConfigDirRole.pm index 8211bdee..636daf06 100644 --- a/lib/ManaTools/ConfigDirRole.pm +++ b/lib/ManaTools/ConfigDirRole.pm @@ -99,4 +99,6 @@ sub configPathName { return $dir . "/" . $self->configName(); } +no Moose::Role; + 1; diff --git a/lib/ManaTools/LoggingRole.pm b/lib/ManaTools/LoggingRole.pm new file mode 100644 index 00000000..198d885d --- /dev/null +++ b/lib/ManaTools/LoggingRole.pm @@ -0,0 +1,98 @@ +# vim: set et ts=4 sw=4: +package ManaTools::LoggingRole; +#============================================================= -*-perl-*- + +=head1 NAME + + Manatools::LoggingRole - Role to manage configuration directory + +=head1 SYNOPSIS + + package Foo; + + use Moose; + with 'Manatools::LoggingRole'; + + sub identifier { + return "logger_identifier"; + } + + ... + $self->logger->I("info message"); + ... + + 1; + +=head1 DESCRIPTION + + LoggingRole just define a role in which a ManaTools::Shared::Logging object can be used to log. + +=head1 SUPPORT + + You can find documentation for this module with the perldoc command: + + perldoc Manatools::LoggingRole + +=head1 SEE ALSO + + ManaTools::Shared::Logging + +=head1 AUTHOR + +Angelo Naselli <anaselli@linux.it> + +=head1 COPYRIGHT and LICENSE + +Copyright (C) 2015, Angelo Naselli. + +This module is free software. You can redistribute it and/or +modify it under the terms of the Artistic License 2.0. + +This program is distributed in the hope that it will be +useful, but without any warranty; without even the implied +warranty of merchantability or fitness for a particular purpose + +=cut + +use Moose::Role; +use ManaTools::Shared::Logging; + +=head2 requires + +=head3 definitions + + identifier: a string that is used as logging identifier + +=cut +#============================================================= + +requires 'identifier'; + +#============================================================= + +=head2 logger + + logger attribute defines the Logging object + see ManaTools::Shared::Logging for details and usage. + +=cut + +#============================================================= +has 'logger' => ( + is => 'ro', + isa => 'ManaTools::Shared::Logging', + init_arg => undef, + lazy => 1, + builder => '_loggerInitialize', +); + +sub _loggerInitialize{ + my $self = shift; + + return ManaTools::Shared::Logging->new(ident => $self->identifier()); +} + + +no Moose::Role; + +1; |