diff --git a/lib/Core/Log.pm b/lib/Core/Log.pm index a136cc8d88f0135bb1c24436cf9a74aa1612318f..e82e324d1f90a3b7fc40578f96a2c21086cc8a1a 100644 --- a/lib/Core/Log.pm +++ b/lib/Core/Log.pm @@ -44,6 +44,11 @@ The name of the file to monitor. Regular expression for matching error lines. +=item maxerrs + +Maximum number of error lines to include in the error string output. Defaults +to 5. + =back =head1 METRICS @@ -67,6 +72,8 @@ sub handler { my $config = $self->{config}; my $file = $config->{filename}; + $config->{maxerrs} = 5 unless exists($config->{maxerrs}); + my @statinfo = stat($file); if (!exists($self->{file_dev}) || @@ -89,8 +96,10 @@ sub handler { while(<$log>) { chomp; if (/$config->{match}/) { - $self->{errstring} .= " " if (length($self->{errstring})); - $self->{errstring} .= $_; + if ($self->{errs} < $config->{maxerrs}) { + $self->{errstring} .= " " if (length($self->{errstring})); + $self->{errstring} .= $_; + } $self->{errs}++; } }