File::Tail::Scribe - Monitor and send the tail of files to a Scribe logging system.
use File::Tail::Scribe; my $log = File::Tail::Scribe->new( directories => $args{dirs}, msg_filter => sub { my ($self, $filename, $line) = @_; return ('info', 'httpd', "$filename\t$line"); }, ); $log->watch_files();
Basically this module connects File::Tail::Dir to Log::Dispatch::Scribe.
It monitors files in a given directory (or set of directories), such as Apache log files in /var/log/httpd, and as the log files are written to, takes the changes and sends them to a running instance of the Scribe logging system.
The Scribe and Thrift Perl modules from their respective source distributions are required and not available as CPAN dependencies. Further information is available here: <http://notes.jschutz.net/109/perl/perl-client-for-facebooks-scribe-logging-software>
$tailer = File::Tail::Scribe->new(%options);
Creates a new instance. Options are:
directories, filter, exclude, follow_symlinks, sleep_interval, statefilename, no_init, max_age
See the equivalent options in File::Tail::Dir: "directories" in File::Tail::Dir, "filter" in File::Tail::Dir, "exclude" in File::Tail::Dir, "follow_symlinks" in File::Tail::Dir, "sleep_interval" in File::Tail::Dir, "statefilename" in File::Tail::Dir, "no_init" in File::Tail::Dir, "max_age" in File::Tail::Dir.
scribe_options
This is a hash containing all of the options to pass to <Log::Dispatch::Scribe/new>.
msg_filter
An optional coderef that can be used to preprocess messages before they are sent to Scribe. The code is passed ($self, $filename, $line), i.e. the File::Tail::Scribe instance, the filename of the file that changed, and the line of text that was added. It must return ($level, $category, $message), i.e. the log level (info, debug etc), the Scribe category, and the log line that will be sent to Scribe. An example:
msg_filter => sub { my $self = shift; my $filename = shift; my $line = shift; $filename =~ s{^.*/}{}; # remove leading dirs $filename =~ s{\.[^.]*$}{}; # remove extension $filename ||= 'default'; # in case everything gets removed return ('info', 'httpd', "$filename\t$line"); };
If no msg_filter is provided, the log level is given by default_level, the category is the filename after removing leading paths and filename extensions, and the message is the log line as given.
default_level
Default logging level. May be set to any valid Log::Dispatch level (debug, info, notice, warning, error, critical, alert, emergency). Defaults to 'info'.
File::Tail::Scribe provides the same methods as File::Tail::Dir, plus the following:
Set/get the "msg_filter" and "default_level" attributes as described above.
tail_to_scribe.pl, a program that uses this module
http://notes.jschutz.net/109/perl/perl-client-for-facebooks-scribe-logging-software
http://github.com/facebook/scribe/
Log::Dispatch::Scribe
Jon Schutz, <jon at jschutz.net> http://notes.jschutz.net
<jon at jschutz.net>
Please report any bugs or feature requests to bug-file-tail-scribe at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=File-Tail-Scribe. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-file-tail-scribe at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc File::Tail::Scribe
You can also look for information at:
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=File-Tail-Scribe
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/File-Tail-Scribe
CPAN Ratings
http://cpanratings.perl.org/d/File-Tail-Scribe
Search CPAN
http://search.cpan.org/dist/File-Tail-Scribe/
Copyright 2010 Jon Schutz, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install File::Tail::Scribe, copy and paste the appropriate command in to your terminal.
cpanm
cpanm File::Tail::Scribe
CPAN shell
perl -MCPAN -e shell install File::Tail::Scribe
For more information on module installation, please visit the detailed CPAN module installation guide.