Commit | Line | Data |
70a05830 |
1 | use strict; |
2 | use warnings; |
3 | |
4 | use Test::More; |
5 | |
afe9b141 |
6 | if (!eval "use Log::Log4perl; |
7 | die if $Log::Log4perl::VERSION < 1.29; |
8 | 1") { |
9 | plan skip_all => 'Log::Log4perl 1.29 not installed' |
70a05830 |
10 | } else { |
11 | plan tests => 2; |
12 | } |
13 | |
14 | use FindBin; |
15 | unlink 'myerrs.log' if -e 'myerrs.log'; |
16 | Log::Log4perl->init("$FindBin::Bin/log4perl.conf"); |
17 | use Log::Contextual qw( :log set_logger ); |
18 | set_logger(Log::Log4perl->get_logger); |
19 | |
20 | log_error { 'err 14' }; |
21 | |
22 | sub foo { |
23 | log_error { 'err 17' }; |
24 | } |
25 | foo(); |
26 | open my $log, '<', 'myerrs.log'; |
27 | my @datas = <$log>; |
28 | close $log; |
29 | |
afe9b141 |
30 | is $datas[0], "file:t/log4perl.t line:20 method:main:: - err 14\n", 'file and line work with Log4perl'; |
31 | is $datas[1], "file:t/log4perl.t line:23 method:main::foo - err 17\n", 'file and line work with Log4perl in a sub'; |
70a05830 |
32 | |