#!perl -T
{
my
$log
= Log::Fine->new(
no_croak
=> 1);
isa_ok(
$log
,
"Log::Fine"
);
can_ok(
$log
,
"name"
);
ok(
$log
->name() =~ /\w\d+$/);
my
$logger
= Log::Fine->logger(
"logger0"
);
isa_ok(
$logger
,
"Log::Fine::Logger"
);
can_ok(
$logger
,
"name"
);
can_ok(
$logger
,
"registerHandle"
);
ok(
$logger
->name() =~ /\w\d+$/);
my
$handle
= Log::Fine::Handle::String->new();
isa_ok(
$handle
,
"Log::Fine::Handle"
);
can_ok(
$handle
,
"name"
);
ok(
$handle
->name() =~ /\w\d+$/);
my
$result
=
$logger
->registerHandle(
$handle
);
isa_ok(
$result
,
"Log::Fine::Logger"
);
can_ok(
$result
,
"name"
);
ok(
$result
->name() =~ /\w\d+$/);
my
$loggerrc
=
$logger
->
log
(DEBG,
"This is a test message"
);
isa_ok(
$loggerrc
,
"Log::Fine::Logger"
);
my
$num
=
$logger
->skip();
ok(
$num
== Log::Fine::Logger->LOG_SKIP_DEFAULT);
$logger
->skip(5);
$num
=
$logger
->skip();
ok(
$num
== 5);
ok(
$logger
->incrSkip() == 6);
ok(
$logger
->decrSkip() == 5);
SKIP: {
eval
"use Test::Output 0.10"
;
skip
"Test::Output 0.10 or above required for testing Console output"
,
3
if
$@;
my
$badlog
=
$log
->logger(
"badlogger"
);
$badlog
->{no_croak} = 1;
stderr_like(
sub
{
my
$foo
= Log::Fine::Logger->new(
no_croak
=> 1);
},
qr/Loggers need names/
,
'logger(): Invoked without name'
);
stderr_like(
sub
{
$badlog
->
log
(INFO,
"It was lightning headaches and sweet avalanche"
);
},
qr/No handles defined/
,
'log(): Invoke without handle'
);
stderr_like(
sub
{
$badlog
->registerHandle() },
qr/must be a valid/
,
'registerHandle(): Invoke without handle'
);
}
}