NAME

HTTP::LoadGen::Logger - a Coro based logger

SYNOPSIS

use HTTP::LoadGen::Logger;

# get a logger
$logger=HTTP::LoadGen::Logger::get $filehandle, $formatter;

# use it
$logger->(@data);

# close it
$logger->();

DESCRIPTION

This module implements a Coro-aware logger. A logger here is a function reference. When called it passes its arguments to the formatter function and pushs the resulting string into a queue. This queue is then processed by a separate Coro thread that runs with the lowest possible priority. The thread prints each line to the $filehandle that was given when the logger was created.

This logger tries to stay out of the way of normal processing as much as possible. The drawback is that when your program has always something other to do all logging output is buffered in RAM.

Functions

$logger=HTTP::LoadGen::Logger::get $filehandle, $formatter

creates a logger that writes to $filehandle.

The logger is then used as:

$logger->(@parameters);

$formatter is expected to be a function reference that returns a string. It is called in scalar context as:

$formatter->(@parameters);

where @parameters are the parameters passed to the logger.

Both $filehandle and $formatter are optional. If omitted STDOUT is used as output stream and

join("\t, @parameters)."\n"

as formatter.

If the logger is called without arguments as:

$logger->();

it is signaled that logging is done. This call waits for the writer thread to write out all remaining data. It returns only after the writer thread is done. Note, the file handle is not closed by this call.

EXPORT

None.

SEE ALSO

HTTP::LoadGen

AUTHOR

Torsten Förtsch, <torsten.foertsch@gmx.net>

COPYRIGHT AND LICENSE

Copyright (C) 2010 by Torsten Förtsch

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.0 or, at your option, any later version of Perl 5 you may have available.