summaryrefslogtreecommitdiff
path: root/t/008ConfCat.t
blob: 98afbca00fd4dd6b098deb0dc3bf020093f2a09f (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
###########################################
# 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;
BEGIN { plan tests => 3 };

use Log::Log4perl;
use Log::Log4perl::Appender::TestBuffer;

my $EG_DIR = "eg";
$EG_DIR = "../eg" unless -d $EG_DIR;

my $date_regex = qr(\d{4}/\d\d/\d\d \d\d:\d\d:\d\d);

ok(1); # If we made it this far, we're ok.

######################################################################
# Test a 'foo.bar.baz' logger which inherits level from foo.bar
# and calls both "foo.bar" and "root" appenders with their respective
# formats
# on a configuration file defining a file appender
######################################################################
Log::Log4perl->init("$EG_DIR/log4j-manual-2.conf");

my $logger = Log::Log4perl->get_logger("foo.bar.baz");
$logger->debug("Gurgel");

ok(Log::Log4perl::Appender::TestBuffer->by_name("A1")->buffer(),
   "m#$date_regex \\[N/A\\] DEBUG foo.bar.baz - Gurgel#");

######################################################################
# Test the root logger via inheritance (discovered by Kevin Goess)
######################################################################
Log::Log4perl->reset();

Log::Log4perl::Appender::TestBuffer->reset();

Log::Log4perl->init("$EG_DIR/log4j-manual-2.conf");

$logger = Log::Log4perl->get_logger("foo");
$logger->debug("Gurgel");

ok(Log::Log4perl::Appender::TestBuffer->by_name("A1")->buffer(),
   "m#$date_regex \\[N/A\\] DEBUG foo - Gurgel#");