The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Tie::Handle::Filter::Output::Timestamp - prepend filehandle output with a timestamp

VERSION

version 0.011

SYNOPSIS

    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

DESCRIPTION

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.

METHODS

TIEHANDLE

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.

EXTENDS

REQUIRES

BUGS AND LIMITATIONS

Because the date and time format is specified using strftime, portable code should restrict itself to formats using ANSI C89 specifiers.

SEE ALSO

Tie::Handle::Filter::Output::Timestamp::EveryLine, which prefixes every line.

AUTHOR

Mark Gardner <mjgardner@cpan.org>

COPYRIGHT AND LICENSE

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.