ARSperl
view release on metacpan or search on metacpan
t/21setlogging.t view on Meta::CPAN
} else {
print "ok [$c]\n";
}
# test appending log messages to ars_errstr
++$c;
my $ret = ars_SetLogging( $ctrl,
&ARS::AR_DEBUG_SERVER_SQL | &ARS::AR_DEBUG_SERVER_FILTER | &ARS::AR_DEBUG_SERVER_API );
if( ! $ret ) {
print "not ok [$c] [$ars_errstr]\n";
} else {
print "ok [$c]\n";
}
++$c;
ars_CreateEntry( $ctrl, 'ARSperl Test', 2 => 'Demo', 7 => 1, 8 => 'ShortDescription' );
if( $ars_errstr =~ /<API >.*<FLTR>.*<SQL >/s ){
print "ok [$c]\n";
} else {
print "not ok [$c]\n";
}
++$c;
$ret = ars_SetLogging( $ctrl, 0 );
if( ! $ret ) {
print "not ok [$c] [$ars_errstr]\n";
} else {
print "ok [$c]\n";
}
# test writing log messages to file
my $logfile = 't/test_SetLogging.log';
unlink $logfile if -f $logfile;
++$c;
$ret = ars_SetLogging( $ctrl,
&ARS::AR_DEBUG_SERVER_SQL | &ARS::AR_DEBUG_SERVER_FILTER | &ARS::AR_DEBUG_SERVER_API,
$logfile );
if( ! $ret ) {
print "not ok [$c] [$ars_errstr]\n";
} else {
print "ok [$c]\n";
}
++$c;
ars_CreateEntry( $ctrl, 'ARSperl Test', 2 => 'Demo', 7 => 1, 8 => 'ShortDescription' );
my $fc;
{
local $/ = undef;
open(FD, $logfile) || die "not ok [$c open]\n";
binmode FD;
$fc = <FD>;
close(FD);
}
if( $fc =~ /<API >.*<FLTR>.*<SQL >/s ){
print "ok [$c]\n";
} else {
print "not ok [$c]\n";
}
++$c;
$ret = ars_SetLogging( $ctrl, 0 );
if( ! $ret ) {
print "not ok [$c] [$ars_errstr]\n";
} else {
print "ok [$c]\n";
}
exit 0;
( run in 0.765 second using v1.01-cache-2.11-cpan-5837b0d9d2c )