Changeset 275 for LATMOS-Accounts/lib
- Timestamp:
- 07/26/09 02:28:51 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
LATMOS-Accounts/lib/LATMOS/Accounts/Log.pm
r253 r275 5 5 use Sys::Syslog qw(:standard :macros); 6 6 use Exporter (); 7 use vars qw(@EXPORT_OK @EXPORT @ISA); 8 @ISA = qw(Exporter); 9 @EXPORT = qw( 10 la_set_log la_log 7 8 =head1 NAME 9 10 LATMOS::Accounts::Log - Log dispatcher for LATMOS::Accounts 11 12 =head1 SYNOPSYS 13 14 use LATMOS::Accounts::Log 15 la_log(LA_ERR, "An error has occur"); 16 17 =head1 DESCRIPTION 18 19 This module provide facilities to log to both console, syslog or using callback. 20 21 When the environement variable C<LA_DEBUG> is set, all message are print to 22 C<stderr>. 23 24 =cut 25 26 our @loglevels = qw( 11 27 LA_EMERG 12 28 LA_ALERT … … 20 36 LA_DEBUG 21 37 ); 38 39 use vars qw(@EXPORT_OK @EXPORT %EXPORT_TAGS @ISA); 40 @ISA = qw(Exporter); 41 @EXPORT = (qw( 42 la_set_log la_log 43 ), @loglevels); 44 22 45 @EXPORT_OK = @EXPORT; 46 %EXPORT_TAGS = (LOGLEVELS => [ @loglevels ]); 23 47 24 48 our $VERSION = (q$Rev$ =~ /^Rev: (\d+) /)[0]; 25 49 50 =head1 LOG LEVEL 51 52 =over 4 53 54 =item LA_EMERG 55 56 =cut 57 26 58 sub LA_EMERG { LOG_EMERG } # system is unusable 59 60 =item LA_ALERT 61 62 =cut 27 63 28 64 sub LA_ALERT { LOG_ALERT } # action must be taken immediately 29 65 66 =item LA_CRIT 67 68 =cut 30 69 sub LA_CRIT { LOG_CRIT } # critical conditions 70 71 =item LA_ERR 72 =item LA_ERROR 73 74 =cut 31 75 32 76 sub LA_ERR { LOG_ERR } # error conditions 33 77 sub LA_ERROR { LA_ERR } # Alias for ERR 34 78 79 =item LA_WARN 80 =item LA_WARNING 81 82 =cut 83 35 84 sub LA_WARNING { LOG_WARNING } # warning conditions 36 85 sub LA_WARN { LA_WARNING } # warning conditions 37 86 87 =item LA_NOTICE 88 89 =cut 90 38 91 sub LA_NOTICE { LOG_NOTICE } # normal, but significant, condition 92 93 =item LA_INFO 94 95 =cut 39 96 40 97 sub LA_INFO { LOG_INFO } # informational message 41 98 99 =item LA_DEBUG 100 101 =cut 102 42 103 sub LA_DEBUG { LOG_DEBUG } # debug-level message 104 105 =back 106 107 =cut 43 108 44 109 my %log_method = ( … … 48 113 ); 49 114 115 =head1 FUNCTIONS 116 117 =head2 la_set_log(%options) 118 119 Set options to log dispatcher: 120 121 =over 4 122 123 =item syslog 124 125 =item console 126 127 =item callback 128 129 =back 130 131 =cut 132 50 133 sub la_set_log { 51 134 my (%options) = @_; … … 54 137 if ($val) { 55 138 my ($ident, $logopt, $facility) = @{ ref $val ? $val : [] }; 56 $ident ||= $$;139 $ident ||= 'LA'; 57 140 $logopt ||= 'pid'; 58 141 $facility ||= 'LOG_USER'; … … 66 149 1; 67 150 } 151 152 =head2 la_log($level, @sprintf_args) 153 154 =cut 68 155 69 156 sub la_log {
Note: See TracChangeset
for help on using the changeset viewer.