BASE . LOG,
'file_id' => $LOG_FILE_ID,
'debug_all' => $DEBUG_ALL,
'print_all' => $PRINT_ALL,
'echo_all' => $ECHO_ALL,
]);
$debug_support_class = 'CoreLibs\Debug\Support';
$debug_logging_class = 'CoreLibs\Debug\Logging';
$PAGE_NAME = 'TEST CLASS: DEBUG';
print "";
print "
" . $PAGE_NAME . "";
print "";
print '';
print '' . $PAGE_NAME . '
';
function test()
{
return DebugSupport::getCallerMethod(1);
}
function test2()
{
return DebugSupport::getCallerMethodList(1);
}
print "S::GETCALLERMETHOD: " . DebugSupport::getCallerMethod(0) . "
";
print "S::GETCALLERMETHOD: " . test() . "
";
print "S::GETCALLERMETHODLIST: " . print_r(test2(), true) . "
";
print "S::PRINTAR: " . DebugSupport::printAr(['Foo', 'Bar']) . "
";
print "V-S::PRINTAR: " . $debug_support_class::printAr(['Foo', 'Bar']) . "
";
print "S::DEBUSTRING(s): " . DebugSupport::debugString('SET') . "
";
print "S::DEBUSTRING(''): " . DebugSupport::debugString('') . "
";
print "S::DEBUSTRING(,s): " . DebugSupport::debugString(null, '{-}') . "
";
// get test
print "LOG FOLDER: " . $debug->getSetting('log_folder') . "
";
// debug
print "C->DEBUG: " . $debug->debug('CLASS-TEST-DEBUG', 'Class Test Debug') . "
";
print "C->DEBUG(html): " . $debug->debug('CLASS-TEST-DEBUG', 'HTML TAG
BOLD') . "
";
print "C->DEBUG(html,strip): " . $debug->debug('CLASS-TEST-DEBUG', 'HTML TAG
BOLD', true) . "
";
print "C->PRINTERRORMSG:
" . $debug->printErrorMsg() . "
";
echo "OPTIONS DEBUG CALL
";
// new log type with options
$new_log = new CoreLibs\Debug\Logging([
'log_folder' => '../log/',
'file_id' => 'DebugTestNewLogger',
// add file date
'print_file_date' => true,
// split into level (debug code)
'per_level' => false,
// per class called
'per_class' => false,
// per page
'per_page' => false,
// for each page call
'per_run' => false,
// set debug and print flags
'debug_all' => true,
'echo_all' => true,
'print_all' => true,
]);
$new_log->debug('OPTIONS TYPE', 'New Type error');
print "OPTIONS LOGGER:
" . $new_log->printErrorMsg();
$new_log->setLogLevel('debug', 'on', ['A', 'B', 'C' => false]);
print "LOG LEVEL: " . DebugSupport::printAr($new_log->getLogLevel('debug', 'on')) . "
";
echo "CLASS DEBUG CALL
";
// @codingStandardsIgnoreLine
class TestL
{
public $log;
public function __construct()
{
$this->log = new CoreLibs\Debug\Logging();
}
public function test(string $ts = null)
{
print "* GETCALLERCLASS(INSIDE CLASS): " . \CoreLibs\Debug\Support::getCallerClass() . "
";
$this->log->debug('TESTL', 'Logging in class testL' . ($ts !== null ? ': ' . $ts : ''));
$this->log->debug('TESTL', 'Some other message');
return true;
}
}
// @codingStandardsIgnoreLine
class TestR extends TestL
{
public $foo;
public function __construct()
{
parent::__construct();
}
public function subTest()
{
print "** GETCALLERCLASS(INSIDE EXTND CLASS): " . \CoreLibs\Debug\Support::getCallerClass() . "
";
$this->log->debug('TESTR', 'Logging in class testR (extends testL)');
$this->test('TESTR INSIDE');
$this->log->debug('TESTR', 'Array: '
. $this->log->prAr(['a', 'b']) . ', Other: ' . $this->log->prAr(['a', 'b']));
return true;
}
}
$tl = new TestL();
print "CLASS: LOG ECHO: " . (string)$tl->log->getLogLevelAll('echo') . "
";
print "CLASS: DEBUG: " . $tl->test() . "
";
print "CLASS: PRINTERRORMSG:
" . $tl->log->printErrorMsg() . "
";
$tr = new TestR();
print "CLASS: LOG ECHO: " . (string)$tr->log->getLogLevelAll('echo') . "
";
print "CLASS EXTEND: DEBUG/tl: " . $tr->test('TESTR OUTSIDE') . "
";
print "CLASS EXTEND: DEBUG/tr: " . $tr->subTest() . "
";
print "CLASS EXTEND: PRINTERRORMSG:
" . $tr->log->printErrorMsg() . "
";
// test attaching a logger from outside
// @codingStandardsIgnoreLine
class AttachOutside
{
public $log;
public function __construct(object $logger_class)
{
$this->log = $logger_class;
}
public function test()
{
$this->log->debug('ATTACHOUTSIDE', 'A test');
return get_class($this);
}
}
$ao = new AttachOutside($debug);
print "AO-CLASS: DEBUG: " . $ao->test() . "
";
print "GETCALLERCLASS(NON CLASS): " . \CoreLibs\Debug\Support::getCallerClass() . "
";
// fdebug
print "S::FSETFILENAME: " . FileWriter::fsetFilename('class_test_debug_file.log') . "
";
print "S::FDEBUG: " . FileWriter::fdebug('CLASS TEST DEBUG FILE: ' . date('Y-m-d H:i:s')) . "
";
// error message
// future DEPRECATED
// $debug->debug('BASIC CLASS', 'Debug test');
$debug->debug('BASIC CLASS', 'Debug test');
print "BASIC PRINTERRORMSG:
" . $debug->printErrorMsg();
print "";
// __END__