I’ll sometimes use the following code at the beginning of a script to 
log errors while testing:

BEGIN {
        use CGI::Carp qw(carpout);
        open(_STDERR,'>&STDERR'); close STDERR;
        open (my $log, '>>', 'logs/error.log') or warn("Couldn't open 
error.log: $! \n");
        carpout($log);
        close ($log);
}

        However, I would like to change the date format.  I’m not wild about 
seeing the the full timestamp on every line:

[Sat Mar 25 08:05:58 2017]

        Is there a way I can format that to my liking?  I see there's a 
‘noTimestamp’ option to stop it from printing altogether, but I don’t see a way 
to change the output.

        Side question: is there a better way to accomplish what I’m doing 
above?  I’m happy with what I already have (except for the date) but only 
because I don’t know anything else.  I’d like to hear how others do this.

Thanks,
Frank
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to