NAME
AsyncLogWatcher - Asynchronously watch log files for specific patterns.
SYNOPSIS
use AsyncLogWatcher;
my $watcher = AsyncLogWatcher->new({
log_dir => "/var/log",
log_file_name => "messages",
patterns_file => "patterns.txt",
exclude_file => "exclude.txt",
});
$watcher->watch();
DESCRIPTION
AsyncLogWatcher is a module that watches a log file for lines matching a given set of patterns. When a line matches one of the patterns and does not match any of the exclude patterns, a callback function is called with the matched line as an argument.
METHODS
- new( \%args )
-
Create a new AsyncLogWatcher instance.
my $watcher = AsyncLogWatcher->new({ log_dir => "/var/log", # Directory of the log file log_file_name => "messages", # Name of the log file patterns_file => "patterns.txt", # File containing patterns to match exclude_file => "exclude.txt", # File containing patterns to exclude });
CALLBACKS
- on_match
-
A callback that is called when a line matches one of the patterns and does not match any of the exclude patterns. The matched line is passed as an argument.
sub { my ($matched_line) = @_; print "Matched line: $matched_line"; }
AUTHOR
Your Name <your-email@example.com>
COPYRIGHT AND LICENSE
Copyright (C) 2023 by Your Name
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.