summaryrefslogtreecommitdiff
path: root/t/005Config-Perl.t
diff options
context:
space:
mode:
Diffstat (limited to 't/005Config-Perl.t')
-rw-r--r--t/005Config-Perl.t58
1 files changed, 58 insertions, 0 deletions
diff --git a/t/005Config-Perl.t b/t/005Config-Perl.t
new file mode 100644
index 0000000..88ac4fb
--- /dev/null
+++ b/t/005Config-Perl.t
@@ -0,0 +1,58 @@
+###########################################
+# 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;
+BEGIN { plan tests => 3 };
+
+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-perl.log";
+unlink $LOGFILE;
+
+Log::Log4perl->init(File::Spec->catfile($EG_DIR, 'log4j-file-append-perl.conf'));
+
+my $logger = Log::Log4perl->get_logger("");
+my $line = __LINE__ + 1;
+$logger->debug("Gurgel");
+
+open LOG, "<$LOGFILE" or die "Cannot open $LOGFILE";
+my $data = <LOG>;
+
+END { close LOG; unlink $LOGFILE; }
+
+is($data, "005Config-Perl.t $line DEBUG N/A - Gurgel\n");
+
+###############################################
+# Check reading a config file via a file handle
+###############################################
+Log::Log4perl->reset();
+open FILE, File::Spec->catfile($EG_DIR, 'log4j-file-append-perl.conf') or
+ die "cannot open log4j-file-append-perl.conf";
+Log::Log4perl->init(\*FILE);
+
+$logger = Log::Log4perl->get_logger("");
+$line = __LINE__ + 1;
+$logger->debug("Gurgel");
+
+$data = <LOG>;
+
+is($data, "005Config-Perl.t $line DEBUG N/A - Gurgel\n");