blob: 198d885d2e2e7286f29c76f96a70d9580706cecb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
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;
|