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\LoggingLegacy';
$PAGE_NAME = 'TEST CLASS: DEBUG';
print "";
print "
" . $PAGE_NAME . "";
print "";
print '';
print '' . $PAGE_NAME . '
';
/**
* Undocumented function
*
* @return string|null
*/
function test(): ?string
{
return DebugSupport::getCallerMethod(1);
}
/**
* Undocumented function
*
* @return array
*/
function test2(): array
{
return DebugSupport::getCallerMethodList(1);
}
print "S::GETCALLERMETHOD: " . DebugSupport::getCallerMethod(0) . "
";
print "S::GETCALLERMETHOD: " . test() . "
";
print "S::GETCALLERMETHODLIST: " . print_r(test2(), true) . "
";
// printAr
print "S::PRINTAR: " . DebugSupport::printAr(['Foo', 'Bar']) . "
";
print "V-S::PRINTAR: " . $debug_support_class::printAr(['Foo', 'Bar']) . "
";
// printBool
print "S::PRINTBOOL(default): " . DebugSupport::printBool(true) . "
";
print "S::PRINTBOOL(name): " . DebugSupport::printBool(true, 'Name') . "
";
print "S::PRINTBOOL(name, ok): " . DebugSupport::printBool(true, 'Name', 'ok') . "
";
print "S::PRINTBOOL(name, ok, not): " . DebugSupport::printBool(false, 'Name', 'ok', 'not') . "
";
// debugString
print "S::DEBUSTRING(s): " . DebugSupport::debugString('SET') . "
";
print "S::DEBUSTRING(s): " . DebugSupport::debugString('SET') . "
";
print "S::DEBUSTRING(s>): " . DebugSupport::debugString('') . "
";
print "S::DEBUSTRING(''): " . DebugSupport::debugString('') . "
";
print "S::DEBUSTRING(,s): " . DebugSupport::debugString(null, '{-}') . "
";
// dumpVar
print "S::DUMPVAR(s): " . DebugSupport::dumpVar('SET') . "
";
print "S::DUMPVAR(s,true): " . DebugSupport::dumpVar('SET', true) . "
";
print "S::DUMPVAR(s>): " . DebugSupport::dumpVar('') . "
";
print "S::DUMPVAR(s>,true): " . DebugSupport::dumpVar('', true) . "
";
print "S::DUMPVAR(''): " . DebugSupport::dumpVar('') . "
";
print "S::DUMPVAR(,s): " . DebugSupport::dumpVar(null) . "
";
print "S::DUMPVAR([a,b]): " . DebugSupport::dumpVar(['a', 'b']) . "
";
print "S::DUMPVAR([a,b],true): " . DebugSupport::dumpVar(['a', 'b'], true) . "
";
print "S::DUMPVAR([MIXED]): " . DebugSupport::dumpVar(<<block
and > and <
EOM) . "
";
// exportVar
// print "S::EXPORTVAR(s): " . DebugSupport::exportVar('SET') . "
";
// print "S::EXPORTVAR(s>): " . DebugSupport::exportVar('') . "
";
// print "S::EXPORTVAR(''): " . DebugSupport::exportVar('') . "
";
// print "S::EXPORTVAR(,s): " . DebugSupport::exportVar(null) . "
";
// print "S::EXPORTVAR([a,b]): " . DebugSupport::exportVar(['a', 'b']) . "
";
// print "S::EXPORTVAR([a,b],true): " . DebugSupport::exportVar(['a', 'b']) . "
";
// 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\LoggingLegacy([
'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(\CoreLibs\Convert\SetVarType::setArray(
$new_log->getLogLevel('debug', 'on')
)) . "
";
echo "CLASS DEBUG CALL
";
// @codingStandardsIgnoreLine
class TestL
{
/** @var \CoreLibs\Debug\LoggingLegacy */
public $log;
public function __construct()
{
$this->log = new CoreLibs\Debug\LoggingLegacy([
'log_folder' => '../log/',
'file_id' => 'DebugTestTestLLogger',
]);
}
/**
* Undocumented function
*
* @param string|null $ts
* @return bool
*/
public function test(?string $ts = null): bool
{
print "* GETCALLERCLASS(INSIDE CLASS): " . \CoreLibs\Debug\Support::getCallerClass() . "
";
print "* GETCALLERTOPCLASS(INSIDE CLASS): " . \CoreLibs\Debug\Support::getCallerTopLevelClass() . "
";
$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
{
/** @var string */
public $foo;
public function __construct()
{
parent::__construct();
}
/**
* Undocumented function
*
* @return bool
*/
public function subTest(): bool
{
print "** GETCALLERCLASS(INSIDE EXTND CLASS): " . \CoreLibs\Debug\Support::getCallerClass() . "
";
print "** GETCALLERTOPCLASS(INSIDE EXTND CLASS): " . \CoreLibs\Debug\Support::getCallerTopLevelClass() . "
";
$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
{
/** @var \CoreLibs\Debug\LoggingLegacy */
public $log;
public function __construct(\CoreLibs\Debug\LoggingLegacy $logger_class)
{
$this->log = $logger_class;
}
/**
* Undocumented function
*
* @return string
*/
public function test(): string
{
$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::fsetFolder(BASE . LOG) . "
";
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')) . "
";
// test per level
$debug->setLogPer('level', true);
$debug->debug('TEST PER LEVEL', 'Per level test');
$debug->debug('()', 'Per level test: invalid chars');
$debug->setLogPer('level', false);
$ar = ['A', 1, ['B' => 'D']];
$debug->debug('ARRAY', 'Array: ' . $debug->prAr($ar));
$debug->debug('BOOL', 'True: ' . $debug->prBl(true) . ', False: ' . $debug->prBl(false));
$debug->debug('MIXED', 'ANYTHING: ' . DebugSupport::dumpVar([
'foo' => 1,
'bar' => null,
'self' => [1, 2, 3],
'other' => false
]));
// error message
// future DEPRECATED
// $debug->debug('BASIC CLASS', 'Debug test');
$debug->debug('BASIC CLASS', 'Debug test');
print "BASIC PRINTERRORMSG:
" . $debug->printErrorMsg();
print "";
// __END__