/usr/share/perl5/Lire/Logger.pm is in lire 2:2.1.1-2.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 | package Lire::Logger;
use strict;
use base qw/ Exporter /;
use vars qw/ @EXPORT $lr_tag /;
use File::Basename;
=pod
=head1 NAME
Lire::Logger - Lire's logging interface.
=head1 SYNOPSIS
Any program:
use Lire::Logger qw/ lr_info lr_debug lr_warn /;
lr_info( "doing stuff " );
lr_debug( "debugging information" );
lr_warn( "encountered unexpected value: ", $value );
open( CFGFILE, "my.conf" ) or lr_err( "open error: ", $! );
=head1 DESCRIPTION
This module contains functions that should be used by everything in
the Lire framework which should need logging.
=cut
BEGIN {
my $prog = basename $0;
my $super = $ENV{'LR_SUPERSERVICE'} || 'all';
my $service = $ENV{'LR_SERVICE'} || 'all';
my $lr_id = $ENV{'LR_ID'} || "UNSET";
$lr_tag = "$super $service $lr_id $prog";
@EXPORT = qw/ lr_emerg lr_crit lr_err lr_warn lr_notice lr_info
lr_debug /;
}
=pod
All logging functions take any number of parameters that will be
joined together to form the message (like print(), die(), warn() and
friends).
=cut
sub label_msg {
my ( $label, @msg ) = @_;
# Maybe remove trailing newline of last part of the message.
chomp $msg[$#msg];
# Add $lr_tag err in front of all lines
my $msg = join "", @msg, "\n";
$msg =~ s/^/$lr_tag $label /mg;
$msg;
}
=pod
=head2 lr_emerg()
This logs a message at the C<emerg> level and aborts your program. This
probably shouldn't be used.
=cut
sub lr_emerg {
my $msg = label_msg( "emerg", @_ );
die $msg;
}
=pod
=head2 lr_crit()
This logs a message at the C<crit> level and aborts your program. This
should only be used when something is really broken in the Lire
program or the environment. It is used a few places in Lire when
assertion that should really never fail (like a DLF file with the
wrong number of fields).
=cut
sub lr_crit {
my $msg = label_msg( "crit", @_ );
die $msg;
}
=pod
=head2 lr_err()
This logs a message at the C<err> level and usually aborts your
program. (It is the equivalent of a die().) The program won't abort if
it's used in an eval block. Uses this for error condition.
=cut
sub lr_err {
my $msg = label_msg( "err", @_ );
die $msg;
}
=pod
=head2 lr_warn()
This logs a message at the C<warning> level. Perl's builtin warn is
mapped to this function. Use this for non-fatal errors.
=cut
sub lr_warn {
my $msg = label_msg( "warning", @_ );
print STDERR $msg;
}
=pod
=head2 lr_notice()
This logs a message at the C<notice> level. This should be used for
significant informational messages that the user should see. (By
default, the user will only see messages at level C<notice> or
higher.)
=cut
sub lr_notice {
my $msg = label_msg( "notice", @_ );
print STDERR $msg;
}
=pod
=head2 lr_info()
This logs a message at the C<info> level. Use this for general
informational messages.
=cut
sub lr_info {
my $msg = label_msg( "info", @_ );
print STDERR $msg;
}
=pod
=head2 lr_debug()
This logs a message at the C<debug> level. Use this for debugging messages.
=cut
sub lr_debug {
my $msg = label_msg( "debug", @_ );
print STDERR $msg;
}
1;
__END__
=pod
=head1 SEE ALSO
Lire::Program(3pm)
=head1 AUTHOR
Francis J. Lacoste <flacoste@logreport.org>
=head1 VERSION
$Id: Logger.pm,v 1.10 2006/07/23 13:16:29 vanbaal Exp $
=head1 COPYRIGHT
Copyright (C) 2001-2003 Stichting LogReport Foundation LogReport@LogReport.org
This file is part of Lire.
Lire is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
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. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program (see COPYING); if not, check with
http://www.gnu.org/copyleft/gpl.html.
=cut
|