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