blob: bf252feff50ab9d3087f23d9b25872d3917c724f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
###########################################
# Test Suite for Log::Log4perl::Config
# Mike Schilli, 2002 (m@perlmeister.com)
###########################################
BEGIN {
if($ENV{INTERNAL_DEBUG}) {
require Log::Log4perl::InternalDebug;
Log::Log4perl::InternalDebug->enable();
}
}
#########################
# change 'tests => 1' to 'tests => last_test_to_print';
#########################
use Test::More;
our $LOG_DISPATCH_PRESENT = 0;
BEGIN {
eval { require Log::Dispatch; };
if($@) {
plan skip_all => "only with Log::Dispatch";
} else {
$LOG_DISPATCH_PRESENT = 1;
plan tests => 2;
}
};
use Log::Log4perl;
use Log::Log4perl::Appender::TestBuffer;
use File::Spec;
my $EG_DIR = "eg";
$EG_DIR = "../eg" unless -d $EG_DIR;
ok(1); # If we made it this far, we're ok.
my $LOGFILE = "example-java.log";
unlink $LOGFILE;
#Log::Log4perl->init(
# File::Spec->catfile($EG_DIR, 'log4j-file-append-java.conf'));
Log::Log4perl->init("$EG_DIR/log4j-file-append-java.conf");
my $logger = Log::Log4perl->get_logger("");
my $lines = ();
my $line = __LINE__ + 1;
push @lines, $line++; $logger->debug("Gurgel");
push @lines, $line++; $logger->info("Gurgel");
push @lines, $line++; $logger->warn("Gurgel");
push @lines, $line++; $logger->error("Gurgel");
push @lines, $line++; $logger->fatal("Gurgel");
open FILE, "<$LOGFILE" or die "Cannot open $LOGFILE";
my $data = join '', <FILE>;
close FILE;
my $file = "t/006Config-Java.t";
my $exp = <<EOT;
$file $lines[0] DEBUG N/A - Gurgel
$file $lines[1] INFO N/A - Gurgel
$file $lines[2] WARN N/A - Gurgel
$file $lines[3] ERROR N/A - Gurgel
$file $lines[4] FATAL N/A - Gurgel
EOT
# Adapt Win32 paths
$data =~ s#\\#/#g;
unlink $LOGFILE;
is($data, "$exp");
|