Changeset 275 for LATMOS-Accounts/lib


Ignore:
Timestamp:
07/26/09 02:28:51 (15 years ago)
Author:
nanardon
Message:
  • fix ident name in syslog
  • provide a basic documentation
File:
1 edited

Legend:

Unmodified
Added
Removed
  • LATMOS-Accounts/lib/LATMOS/Accounts/Log.pm

    r253 r275  
    55use Sys::Syslog qw(:standard :macros); 
    66use 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 
     10LATMOS::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 
     19This module provide facilities to log to both console, syslog or using callback. 
     20 
     21When the environement variable C<LA_DEBUG> is set, all message are print to 
     22C<stderr>. 
     23 
     24=cut 
     25 
     26our @loglevels = qw( 
    1127    LA_EMERG 
    1228    LA_ALERT 
     
    2036    LA_DEBUG 
    2137); 
     38 
     39use vars qw(@EXPORT_OK @EXPORT %EXPORT_TAGS @ISA); 
     40@ISA = qw(Exporter); 
     41@EXPORT = (qw( 
     42    la_set_log la_log 
     43    ), @loglevels); 
     44 
    2245@EXPORT_OK = @EXPORT; 
     46%EXPORT_TAGS = (LOGLEVELS => [ @loglevels ]); 
    2347 
    2448our $VERSION = (q$Rev$ =~ /^Rev: (\d+) /)[0]; 
    2549 
     50=head1 LOG LEVEL 
     51 
     52=over 4 
     53 
     54=item LA_EMERG 
     55 
     56=cut 
     57 
    2658sub LA_EMERG { LOG_EMERG } # system is unusable 
     59 
     60=item LA_ALERT 
     61 
     62=cut 
    2763 
    2864sub LA_ALERT { LOG_ALERT } # action must be taken immediately 
    2965 
     66=item LA_CRIT 
     67 
     68=cut 
    3069sub LA_CRIT { LOG_CRIT } # critical conditions 
     70 
     71=item LA_ERR 
     72=item LA_ERROR 
     73 
     74=cut 
    3175 
    3276sub LA_ERR   { LOG_ERR } # error conditions 
    3377sub LA_ERROR { LA_ERR } # Alias for ERR 
    3478 
     79=item LA_WARN 
     80=item LA_WARNING 
     81 
     82=cut 
     83 
    3584sub LA_WARNING { LOG_WARNING } # warning conditions 
    3685sub LA_WARN    { LA_WARNING } # warning conditions 
    3786 
     87=item LA_NOTICE 
     88 
     89=cut 
     90 
    3891sub LA_NOTICE { LOG_NOTICE } # normal, but significant, condition 
     92 
     93=item LA_INFO 
     94 
     95=cut 
    3996 
    4097sub LA_INFO { LOG_INFO } # informational message 
    4198 
     99=item LA_DEBUG 
     100 
     101=cut 
     102 
    42103sub LA_DEBUG { LOG_DEBUG } # debug-level message 
     104 
     105=back 
     106 
     107=cut 
    43108 
    44109my %log_method = ( 
     
    48113); 
    49114 
     115=head1 FUNCTIONS 
     116 
     117=head2 la_set_log(%options) 
     118 
     119Set 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 
    50133sub la_set_log { 
    51134    my (%options) = @_; 
     
    54137            if ($val) { 
    55138                my ($ident, $logopt, $facility) =  @{ ref $val ? $val : [] }; 
    56                 $ident ||= $$; 
     139                $ident ||= 'LA'; 
    57140                $logopt ||= 'pid'; 
    58141                $facility ||= 'LOG_USER'; 
     
    66149    1; 
    67150} 
     151 
     152=head2 la_log($level, @sprintf_args) 
     153 
     154=cut 
    68155 
    69156sub la_log { 
Note: See TracChangeset for help on using the changeset viewer.