#!perl -T
my
$msg
=
"Stop by this disaster town, we put our eyes to the sun and say 'Hello!'"
;
my
$handle
= Log::Fine::Handle::Console->new();
{
eval
"use Test::Output 0.10"
;
if
($@) {
plan
skip_all
=>
"Test::Output 0.10 or above required for testing Console output"
;
}
else
{
plan
tests
=> 17;
}
isa_ok(
$handle
,
"Log::Fine::Handle::Console"
);
can_ok(
$handle
,
"name"
);
ok(
$handle
->name() =~ /\w\d+$/);
my
$log
= Log::Fine->logger(
"handleconsole0"
);
isa_ok(
$log
,
"Log::Fine"
);
can_ok(
$log
,
"name"
);
ok(
$log
->name() =~ /\w\d+$/);
isa_ok(
$handle
,
"Log::Fine::Handle"
);
isa_ok(
$handle
->{formatter},
"Log::Fine::Formatter::Basic"
);
can_ok(
$handle
,
"name"
);
can_ok(
$handle
,
"msgWrite"
);
ok(
$handle
->name() =~ /\w\d+$/);
ok(
$handle
->{mask} ==
$handle
->levelMap()->bitmaskAll());
ok(
$handle
->{formatter}->isa(
"Log::Fine::Formatter::Basic"
));
ok(!
$handle
->{use_stderr});
stdout_like(\
&writer
,
qr/$msg/
,
'Test STDOUT'
);
$handle
->{use_stderr} = 1;
ok(
$handle
->{use_stderr});
stderr_like(\
&writer
,
qr/$msg/
,
'Test STDERR'
);
}
sub
writer
{
$handle
->msgWrite(INFO,
$msg
);
}