AnyEvent::Multilog - event-driven interface to a multilog process
version 1.102861
my $log = AnyEvent::Multilog->new( script => [qw{t +* ./log}], ); $log->start; $log->push_write('log message'); $log->push_write('another log message'); $log->rotate; $log->push_write('another log message in a new log file'); $log->shutdown;
This module makes it easy to log via a multilog process. It handles spawning the multilog process and handling its errors.
Required.
This is an ArrayRef representing the multilog script that describes how to log. See the multilog for more information on what this script is and how to write one.
Note that the shell is never invoked, so you don't need to escape anything from the shell.
To select all lines, add a tai64n timestamp, and log to a directory called "log", your script should be ['t', '+*', './log'].
['t', '+*', './log']
Optional.
The path to the multilog binary. By default, checks $PATH and uses the one in there.
$PATH
Coderef that is called when the multilog process exists, successfully or otherwise.
Your coderef is passed three arguments, a boolean indicating successful exit, a message indicating why multilog exited, and the AnyEvent::Subprocess::Done object representing the exited subprocess.
Coderef to be called when multilog writes something to stderr. It's assumed that logging can't proceed after something is read from stderr, so all methods will die regardless of whether or not you handle this callback. Handling this event lets you proactively spawn a new logger and kill this one without losing any messages.
Patch welcome to make this automatic. I can't get multilog to die on my machine.
Call this when you are ready to fork off the multilog and start logging. If you call another method before calling this, the results are undefined.
Send a line to multilog. If you don't provide a newline, one will be provided for you.
Ask multilog to rotate the log right now.
Ask multilog to shut down after writing the current line to disk. Any pending data is made available via $self->leftover_data, which can be checked for with $self->has_leftover_data.
$self->leftover_data
$self->has_leftover_data
When multilog is done writing, your on_exit callback will be called.
on_exit
Shutdown immediately by closing the file descriptor that multilog is reading from.
Returns true if multilog is done.
Returns true if multilog exited without reading some data we asked it to log.
Returns any data that multilog did not write before exiting.
Returns true if errors were encourntered.
Returns a list of errors that were encountered.
Jonathan Rockway <jrockway@cpan.org>
This software is copyright (c) 2011 by Jonathan Rockway.
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 AnyEvent::Multilog, copy and paste the appropriate command in to your terminal.
cpanm
cpanm AnyEvent::Multilog
CPAN shell
perl -MCPAN -e shell install AnyEvent::Multilog
For more information on module installation, please visit the detailed CPAN module installation guide.