Re: Changing date format using carpout

2017-03-26 Thread X Dungeness
The rest of it: use Time::Piece; use CGI::Carp (carpout); { local *CGI::Carp::stamp = sub {... }; open( my $log, ">>", "/path/to/error.log") or die $!; carpout($log); carp("foo happened"); # close($log) } carp("foo again but with module's timestamp"); On Sun, Mar 26, 2017 at 3:04

Re: Changing date format using carpout

2017-03-26 Thread X Dungeness
Shawn may have a different take but I think the "local" is misplaced and goes out of scope when the call's made. Here's a potential workaround: out of scope On Sun, Mar 26, 2017 at 2:02 PM, SSC_perl wrote: >> On Mar 26, 2017, at 1:15 PM, Shawn H Corey

Re: Changing date format using carpout

2017-03-26 Thread SSC_perl
> On Mar 26, 2017, at 1:15 PM, Shawn H Corey 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

Re: Changing date format using carpout

2017-03-26 Thread Shawn H Corey
On Sun, 26 Mar 2017 11:28:44 -0700 SSC_perl wrote: > > On Mar 25, 2017, at 8:58 PM, Jim Gibson > > wrote: > > > > You could also try overriding the supplied function of the imported > > module with your own version (not sure exactly how that is

Re: Changing date format using carpout

2017-03-26 Thread SSC_perl
> On Mar 26, 2017, at 1:20 AM, X Dungeness wrote: > > but you could post-process the logfile in an END {} block I wouldn't have thought of that. Thanks! This now gives me a cleaner log to scan — streamlining the timestamp and adding a blank line between

Re: Changing date format using carpout

2017-03-26 Thread SSC_perl
> On Mar 25, 2017, at 8:58 PM, Jim Gibson wrote: > > You could also try overriding the supplied function of the imported module > with your own version (not sure exactly how that is done). Hmm… me neither, but it’s a good idea. I’ll contact the maintainer of

Re: Changing date format using carpout

2017-03-26 Thread X Dungeness
Certainly an inefficient, unwieldy solution if you're dealing with huge logfiles. May be problematic on non-Unix too but you could post-process the logfile in an END {} block eg, get rid of hr:min:ss part of timestamp for example: END { $^I = ''; @ARGV = qw( /path/to/error.log);