timestamp in STDERR output

Dave Hodgkinson davehodg at gmail.com
Thu Jun 29 17:16:33 BST 2006


beerpal it to him


On 29 Jun 2006, at 15:45, Thomas Busch wrote:

> many thanks. That's exactly what I wanted. I owe you a beer.
>
> thomas.
>
>> On Thu, Jun 29, 2006 at 04:02:46PM +0200, Thomas Busch wrote:
>>
>>> is it possible to redefine STDERR in such a way that
>>> you get a timestamp at the beginning of each line ?
>>
>> #!/usr/bin/perl
>> use strict;
>> use warnings;
>>
>> use Tie::STDERR \&timestamper;
>>
>> sub timestamper {
>>     local *STDERR;
>>     untie *STDERR;
>>     print time().': '.$_[0];
>> }
>>
>> warn "now with timestamps!\n";
>>
>> -- 
>> David Cantrell | http://www.cantrell.org.uk/david
>>
>> Computer Science is about lofty design goals and careful algorithmic
>> optimisation.  Sysadminning is about cleaning up the resulting mess.
>>
>
>
>

-- 
Dave Hodgkinson - Music photography
http://www.davehodgkinson.com/




More information about the london.pm mailing list