Last active
August 29, 2015 13:57
-
-
Save mdjunior/9369937 to your computer and use it in GitHub Desktop.
log_wrapper for perl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sub log_wrapper { | |
my $log = shift; | |
my $priority = shift; | |
if ( ! defined $priority ) { | |
$priority = 'debug'; | |
} | |
if ( $ENV{APP_LOG} eq 'LOCAL' ) { | |
openlog( $ENV{APP_NAME}, 'ndelay,pid', 'LOG_DAEMON' ); | |
syslog( $priority, $log ); | |
closelog(); | |
} elsif ($ENV{APP_LOG} eq 'NET') { | |
my $log_net = Net::Syslog->new( | |
Name => $ENV{APP_NAME}, | |
Facility => 'local7', | |
Priority => $priority, | |
SyslogPort => $ENV{APP_SYSLOG_PORT}, | |
SyslogHost => $ENV{APP_SYSLOG_HOST}, | |
); | |
$log_net->send($log); | |
} | |
return; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment