aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ManaTools
diff options
context:
space:
mode:
authorAngelo Naselli <anaselli@linux.it>2015-08-05 11:19:48 +0200
committerAngelo Naselli <anaselli@linux.it>2015-08-05 11:19:48 +0200
commit1435dd35e9f18527da90edb0de6e639281a7d2b1 (patch)
treea4d3daa4fb653e2e70b0d4b1ce1cd9eabc6c5c1e /lib/ManaTools
parent61f7a70f55d186507a9fc0ef652e92d0b72fb59a (diff)
downloadmanatools-1435dd35e9f18527da90edb0de6e639281a7d2b1.tar
manatools-1435dd35e9f18527da90edb0de6e639281a7d2b1.tar.gz
manatools-1435dd35e9f18527da90edb0de6e639281a7d2b1.tar.bz2
manatools-1435dd35e9f18527da90edb0de6e639281a7d2b1.tar.xz
manatools-1435dd35e9f18527da90edb0de6e639281a7d2b1.zip
Added identifier on logging (see Sys::Syslog)
Diffstat (limited to 'lib/ManaTools')
-rw-r--r--lib/ManaTools/Shared/Logging.pm68
1 files changed, 68 insertions, 0 deletions
diff --git a/lib/ManaTools/Shared/Logging.pm b/lib/ManaTools/Shared/Logging.pm
index 71be268a..e2f31eb3 100644
--- a/lib/ManaTools/Shared/Logging.pm
+++ b/lib/ManaTools/Shared/Logging.pm
@@ -93,6 +93,74 @@ has 'loc' => (
#=============================================================
+=head2 new
+
+=head3 INPUT
+
+ hash ref containing
+ ident: optional string used as identifier into syslog
+
+=head3 DESCRIPTION
+
+ new is inherited from Moose, to create a Logging object
+
+=cut
+
+#=============================================================
+has 'ident' => (
+ is => 'ro',
+ isa => 'Str',
+ default => ''
+);
+
+#=============================================================
+
+=head2 BUILD
+
+=head3 INPUT
+
+ $self: this object
+
+=head3 DESCRIPTION
+
+ The BUILD method is called after a Moose object is created,
+ Into this method additional data are initialized.
+ This method just calls openlog if "ident" is set.
+
+=cut
+
+#=============================================================
+sub BUILD {
+ my $self = shift;
+
+ Sys::Syslog::openlog($self->ident) if $self->ident;
+}
+
+#=============================================================
+
+=head2 DEMOLISH
+
+=head3 INPUT
+
+ $val: boolean value indicating whether or not this method
+ was called as part of the global destruction process
+ (when the Perl interpreter exits)
+
+=head3 DESCRIPTION
+
+ Moose provides a hook for object destruction with the
+ DEMOLISH method as it does for construtor with BUILD
+
+=cut
+
+#=============================================================
+sub DEMOLISH {
+ my ($self, $val) = @_;
+
+ Sys::Syslog::closelog();
+}
+#=============================================================
+
=head2 R
=head3 INPUT