2017-08-31 19:15:44 -04:00
|
|
|
####################################################################################################################################
|
|
|
|
# CommonLogTest.pm - Unit tests for Log module
|
|
|
|
####################################################################################################################################
|
2018-01-16 12:36:22 -05:00
|
|
|
package pgBackRestTest::Module::Common::CommonLogPerlTest;
|
2017-08-31 19:15:44 -04:00
|
|
|
use parent 'pgBackRestTest::Common::RunTest';
|
|
|
|
|
|
|
|
####################################################################################################################################
|
|
|
|
# Perl includes
|
|
|
|
####################################################################################################################################
|
|
|
|
use strict;
|
|
|
|
use warnings FATAL => qw(all);
|
|
|
|
use Carp qw(confess);
|
|
|
|
use English '-no_match_vars';
|
|
|
|
|
|
|
|
use pgBackRest::Common::Exception;
|
|
|
|
use pgBackRest::Common::Ini;
|
|
|
|
use pgBackRest::Common::Log;
|
|
|
|
use pgBackRest::Version;
|
|
|
|
|
|
|
|
use pgBackRestTest::Common::ExecuteTest;
|
|
|
|
use pgBackRestTest::Common::RunTest;
|
|
|
|
|
|
|
|
####################################################################################################################################
|
|
|
|
# run
|
|
|
|
####################################################################################################################################
|
|
|
|
sub run
|
|
|
|
{
|
|
|
|
my $self = shift;
|
|
|
|
|
|
|
|
################################################################################################################################
|
|
|
|
if ($self->begin("log()"))
|
|
|
|
{
|
|
|
|
logWarnOnErrorEnable();
|
|
|
|
$self->testResult(sub {&log(ERROR, "my test log", 27)}, "[object]", 'log error as warning',
|
|
|
|
{strLogExpect => "WARN: [027]: my test log"});
|
|
|
|
|
2017-09-19 10:03:53 -04:00
|
|
|
$self->testResult(sub {&log(INFO, "my test log")}, "my test log", 'log info as info',
|
|
|
|
{strLogLevel => INFO, strLogExpect => "INFO: my test log"});
|
|
|
|
|
2017-08-31 19:15:44 -04:00
|
|
|
logWarnOnErrorDisable();
|
|
|
|
$self->testResult(sub {&log(ERROR, "my test log", 27)}, "[object]", 'log error',
|
|
|
|
{strLogExpect => "ERROR: [027]: my test log"});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
1;
|