| 1 | package EJBCA::CrlPublish::Logging; | ||
| 2 | use warnings; | ||
| 3 | use strict; | ||
| 4 | # | ||
| 5 | # crlpublish | ||
| 6 | # | ||
| 7 | # Copyright (C) 2014, Kevin Cody-Little <kcody@cpan.org> | ||
| 8 | # | ||
| 9 | # Portions derived from crlpublisher.sh, original copyright follows: | ||
| 10 | # | ||
| 11 | # Copyright (C) 2011, Branko Majic <branko@majic.rs> | ||
| 12 | # | ||
| 13 | # This program is free software: you can redistribute it and/or modify | ||
| 14 | # it under the terms of the GNU General Public License as published by | ||
| 15 | # the Free Software Foundation, either version 3 of the License, or | ||
| 16 | # (at your option) any later version. | ||
| 17 | # | ||
| 18 | # This program is distributed in the hope that it will be useful, | ||
| 19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 21 | # GNU General Public License for more details. | ||
| 22 | # | ||
| 23 | # You should have received a copy of the GNU General Public License | ||
| 24 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 25 | # | ||
| 26 | ############################################################################### | ||
| 27 | |||
| 28 | =head1 NAME | ||
| 29 | |||
| 30 | EJBCA::CrlPublish::Logging | ||
| 31 | |||
| 32 | =head1 SYNOPSIS | ||
| 33 | |||
| 34 | Central logging implementation. | ||
| 35 | |||
| 36 | Exports &msgDebug &msgError | ||
| 37 | |||
| 38 | =cut | ||
| 39 | |||
| 40 | |||
| 41 | ############################################################################### | ||
| 42 | # Library Dependencies | ||
| 43 | |||
| 44 | use base 'Exporter'; | ||
| 45 | |||
| 46 | our @EXPORT = qw( msgDebug msgError ); | ||
| 47 | our $VERSION = '0.60'; | ||
| 48 | our $DODEBUG = 0; | ||
| 49 | |||
| 50 | |||
| 51 | ############################################################################### | ||
| 52 | # Intercept STDIO if they aren't terminals. | ||
| 53 | |||
| 54 | sub BEGIN { | ||
| 55 | |||
| 56 | no strict 'vars'; | ||
| 57 | |||
| 58 | unless ( -t STDOUT ) { | ||
| 59 | open STDOUT, ">> /var/log/crlpublish.log"; | ||
| 60 | open STDERR, ">&1" | ||
| 61 | } | ||
| 62 | |||
| 63 | } | ||
| 64 | |||
| 65 | |||
| 66 | ############################################################################### | ||
| 67 | # | ||
| 68 | |||
| 69 | sub msgDebug { | ||
| 70 | return unless $DODEBUG; | ||
| 71 | warn 'DEBUG: ', @_, "\n"; | ||
| 72 | } | ||
| 73 | |||
| 74 | sub msgError { | ||
| 75 | warn 'ERROR: ', @_, "\n"; | ||
| 76 | } | ||
| 77 | |||
| 78 | |||
| 79 | ############################################################################### | ||
| 80 | |||
| 81 | =head1 AUTHOR | ||
| 82 | |||
| 83 | Kevin Cody-Little <kcody@cpan.org> | ||
| 84 | |||
| 85 | =cut | ||
| 86 | |||
| 87 | |||
| 88 | ############################################################################### | ||
| 89 | ####################################### EOF ################################### | ||
| 90 | ############################################################################### | ||
| 91 | 1; |