> On Mar 26, 2017, at 1:15 PM, Shawn H Corey <[email protected]> wrote:
>
> it would mean replacing the subroutine after the module was loaded.
Thanks, Shawn, but I can’t get that to work. Reading perldoc Core
gives me the impression that I’d need to call the new sub, not the module. If
that’s true, I don’t see how it would work in this scenario. Here’s what I
tried:
BEGIN {
use CGI::Carp qw(carpout fatalsToBrowser ); # noTimestamp
{
no warnings;
use Time::Piece;
local *CGI::Carp::stamp = sub {
my $frame = 0;
my ($id, $pack, $file, $dev, $dirs);
if (defined($CGI::Carp::PROGNAME)) {
$id = $CGI::Carp::PROGNAME;
} else {
do {
$id = $file;
($pack, $file) = caller($frame++);
} until !$file;
}
if (! $CGI::Carp::FULL_PATH) {
($dev, $dirs, $id) = File::Spec->splitpath($id);
}
return "$id: " if $CGI::Carp::NO_TIMESTAMP;
my $time = scalar(localtime);
my $dt = Time::Piece->strptime($time, '%a %b %d %H:%M:%S %Y');
my $datetime = $dt->strftime('%Y-%m-%d %H:%M');
return "[$datetime] $id: ";
}
}
open (my $log, '>>', ‘/path/to/error.log');
carpout($log);
close ($log);
}
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/