NAME

TestCommon::LogDiff - get log file diffs

Synopsis

use TestCommon::LogDiff;
use Apache::Test;

plan tests => 2;

my $path = "/tmp/mylog";
open my $fh, ">>$path" or die "Can't open $path: $!";

my $logdiff = TestCommon::LogDiff->new($path);

print $fh "foo 123\n";
my $expected = qr/^foo/;
ok t_cmp $logdiff->diff, $expected;

print $fh "bar\n";
my $expected = 'bar';
ok t_cmp $logdiff->diff, $expected;

Description

Useful for testing the warning, error and other messages going into the log file.

API

new

open the log file and point the filehandle pointer to its end.

diff

extract any newly logged information since the last check and move the filehandle to the end of the file.