Enjoy it.
use strict;
use warnings;
use Fcntl qw(:DEFAULT :flock);
# Catch fatal errors.
$SIG{__DIE__} = \&write_error;
# Log Perl Warnings and Errors - Improved
use CGI::Carp qw(carpout);
sysopen(LOG_WARN, '/log_path/db/error.log', O_WRONLY | O_APPEND)
or die "Unable to append to error-log: at $!\n";
carpout(\*LOG_WARN);
sub write_error {
my $error_msg = shift;
if ($error_msg) {
$error_msg =~ s/\n/ /g;
$error_msg =~ s/\|/|/g;
}
# Update log file.
my $date = '[' . scalar(localtime) . ']|' . $error_msg;
sysopen(FH, '/log_path/db/fatal_error.log', O_WRONLY | O_APPEND) or d
+ie $!;
flock(FH, LOCK_EX);
print FH $date . "\n";
close(FH);
}
Stewie: You know, I rather like this God fellow. Very theatrical, you know. Pestilence here, a plague there. Omnipotence ... gotta get me some of that.