Tie::Handle::Filter::Output::Timestamp - prepend filehandle output with a timestamp
version 0.011
use Tie::Handle::Filter::Output::Timestamp; tie *STDOUT, 'Tie::Handle::Filter::Output::Timestamp', *STDOUT; print "Everything I print will be prepended with a timestamp.\n"; print <<'END_OUTPUT'; The first line of a multi-line string will be prepended. Subsequent lines will not. END_OUTPUT
This class may be used with Perl's tie function to prepend all output with a timestamp, optionally formatted according to the POSIX strftime function. Only the beginning of strings given to print, printf, syswrite, and say (in Perl > v5.10) get timestamps.
strftime
print
printf
syswrite
say
Invoked by the command tie *glob, 'Tie::Handle::Filter::Output::Timestamp', *glob. You may also specify a strftime string as an additional parameter to format the timestamp; by default the format is %x %X , which is the local representation of the date and time followed by a space.
tie *glob, 'Tie::Handle::Filter::Output::Timestamp', *glob
%x %X
Tie::Handle::Filter
POSIX
Because the date and time format is specified using strftime, portable code should restrict itself to formats using ANSI C89 specifiers.
Tie::Handle::Filter::Output::Timestamp::EveryLine, which prefixes every line.
Mark Gardner <mjgardner@cpan.org>
This software is copyright (c) 2016 by cPanel, Inc.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Tie::Handle::Filter, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Tie::Handle::Filter
CPAN shell
perl -MCPAN -e shell install Tie::Handle::Filter
For more information on module installation, please visit the detailed CPAN module installation guide.