Skip to content

Instantly share code, notes, and snippets.

@mdjunior
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mdjunior/9369937 to your computer and use it in GitHub Desktop.
Save mdjunior/9369937 to your computer and use it in GitHub Desktop.
log_wrapper for perl
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