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