in reply to Formatting STDERR
merlyn has a nifty routine for that, which I shamelessly stole for Simple HTTP in under 100 lines :
$SIG{__WARN__} = sub { warn __stamp(shift) }; $SIG{__DIE__} = sub { die __stamp(shift) }; # This sub Copyright (c) 1996,97,98,99,2000,01 by Randal L. Schwartz sub __stamp { my ($message) = @_; my $stamp = sprintf "[$$] [%02d@%02d:%02d:%02d] ", localtime[3,2,1,0 +]; $message =~ s/^/$stamp/gm; $message; }
After that, all your output to STDERR (warnings, dies) will be prefixed with the (time)stamp.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Formatting STDERR
by Abigail-II (Bishop) on Feb 12, 2004 at 10:09 UTC |