HTTP::LoadGen::Logger - a Coro based logger
use HTTP::LoadGen::Logger; # get a logger $logger=HTTP::LoadGen::Logger::get $filehandle_or_name, $formatter; # use it $logger->(@data); # close it $logger->();
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.
$filehandle
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.
creates a logger that writes to $filehandle.
If a file name is passed it is opened to append. On open failure an execption is thrown.
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
$formatter->(@parameters);
where @parameters are the parameters passed to the logger.
@parameters
Both $filehandle and $formatter are optional. If omitted STDOUT is used as output stream and
STDOUT
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.
None.
HTTP::LoadGen
Torsten Förtsch, <torsten.foertsch@gmx.net>
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.
To install HTTP::LoadGen, copy and paste the appropriate command in to your terminal.
cpanm
cpanm HTTP::LoadGen
CPAN shell
perl -MCPAN -e shell install HTTP::LoadGen
For more information on module installation, please visit the detailed CPAN module installation guide.