Logging class major change, Debug\Support update

old Debug\Logging is in Debug\LoggingLegacy and Debug\Logging extends
Logging\Logging

Logging\Logging is a new class with most of the functionality except
there is no more print/outout to screen, but we use the default log
levels (RFC5424)
The plan is to be a frontend between the old type class and
Monolog\Monolog

Updated all other classes to use new class interface
This commit is contained in:
Clemens Schwaighofer
2023-05-30 18:12:24 +09:00
parent 7b5ad92e66
commit b0a8783276
75 changed files with 4292 additions and 2019 deletions

View File

@@ -7,7 +7,6 @@
declare(strict_types=1);
// all the settings are overruled by config
$DEBUG_ALL_OVERRIDE = true; // set to 1 to debug on live/remote server locations
$DEBUG_ALL = true;
$PRINT_ALL = false;
$ECHO_ALL = true;
@@ -32,7 +31,7 @@ $ECHO_ALL = true;
use CoreLibs\Debug\Support as DebugSupport;
use CoreLibs\Debug\FileWriter;
$debug = new CoreLibs\Debug\Logging([
$debug = new CoreLibs\Debug\LoggingLegacy([
'log_folder' => BASE . LOG,
'file_id' => $LOG_FILE_ID,
'debug_all' => $DEBUG_ALL,
@@ -40,7 +39,7 @@ $debug = new CoreLibs\Debug\Logging([
'echo_all' => $ECHO_ALL,
]);
$debug_support_class = 'CoreLibs\Debug\Support';
$debug_logging_class = 'CoreLibs\Debug\Logging';
$debug_logging_class = 'CoreLibs\Debug\LoggingLegacy';
$PAGE_NAME = 'TEST CLASS: DEBUG';
print "<!DOCTYPE html>";
@@ -72,16 +71,43 @@ function test2(): array
print "S::GETCALLERMETHOD: " . DebugSupport::getCallerMethod(0) . "<br>";
print "S::GETCALLERMETHOD: " . test() . "<br>";
print "S::GETCALLERMETHODLIST: <pre>" . print_r(test2(), true) . "</pre><br>";
// printAr
print "S::PRINTAR: " . DebugSupport::printAr(['Foo', 'Bar']) . "<br>";
print "V-S::PRINTAR: " . $debug_support_class::printAr(['Foo', 'Bar']) . "<br>";
// printBool
print "S::PRINTBOOL(default): " . DebugSupport::printBool(true) . "<br>";
print "S::PRINTBOOL(name): " . DebugSupport::printBool(true, 'Name') . "<br>";
print "S::PRINTBOOL(name, ok): " . DebugSupport::printBool(true, 'Name', 'ok') . "<br>";
print "S::PRINTBOOL(name, ok, not): " . DebugSupport::printBool(false, 'Name', 'ok', 'not') . "<br>";
// debugString
print "S::DEBUSTRING(s): " . DebugSupport::debugString('SET') . "<br>";
print "S::DEBUSTRING(s): " . DebugSupport::debugString('SET') . "<br>";
print "S::DEBUSTRING(s&gt;): " . DebugSupport::debugString('<SET>') . "<br>";
print "S::DEBUSTRING(''): " . DebugSupport::debugString('') . "<br>";
print "S::DEBUSTRING(,s): " . DebugSupport::debugString(null, '{-}') . "<br>";
// dumpVar
print "S::DUMPVAR(s): " . DebugSupport::dumpVar('SET') . "<br>";
print "S::DUMPVAR(s,true): " . DebugSupport::dumpVar('SET', true) . "<br>";
print "S::DUMPVAR(s&gt;): " . DebugSupport::dumpVar('<SET>') . "<br>";
print "S::DUMPVAR(s&gt;,true): " . DebugSupport::dumpVar('<SET>', true) . "<br>";
print "S::DUMPVAR(''): " . DebugSupport::dumpVar('') . "<br>";
print "S::DUMPVAR(,s): " . DebugSupport::dumpVar(null) . "<br>";
print "S::DUMPVAR([a,b]): " . DebugSupport::dumpVar(['a', 'b']) . "<br>";
print "S::DUMPVAR([a,b],true): " . DebugSupport::dumpVar(['a', 'b'], true) . "<br>";
print "S::DUMPVAR([MIXED]): " . DebugSupport::dumpVar(<<<EOM
Line is
break
with
<html>block</html>
and > and <
EOM) . "<br>";
// exportVar
// print "S::EXPORTVAR(s): " . DebugSupport::exportVar('SET') . "<br>";
// print "S::EXPORTVAR(s&gt;): " . DebugSupport::exportVar('<SET>') . "<br>";
// print "S::EXPORTVAR(''): " . DebugSupport::exportVar('') . "<br>";
// print "S::EXPORTVAR(,s): " . DebugSupport::exportVar(null) . "<br>";
// print "S::EXPORTVAR([a,b]): " . DebugSupport::exportVar(['a', 'b']) . "<br>";
// print "S::EXPORTVAR([a,b],true): " . DebugSupport::exportVar(['a', 'b']) . "<br>";
// get test
print "LOG FOLDER: " . $debug->getSetting('log_folder') . "<br>";
@@ -95,7 +121,7 @@ print "C->PRINTERRORMSG: <br>" . $debug->printErrorMsg() . "<br>";
echo "<b>OPTIONS DEBUG CALL</b><br>";
// new log type with options
$new_log = new CoreLibs\Debug\Logging([
$new_log = new CoreLibs\Debug\LoggingLegacy([
'log_folder' => '../log/',
'file_id' => 'DebugTestNewLogger',
// add file date
@@ -125,11 +151,11 @@ echo "<b>CLASS DEBUG CALL</b><br>";
// @codingStandardsIgnoreLine
class TestL
{
/** @var \CoreLibs\Debug\Logging */
/** @var \CoreLibs\Debug\LoggingLegacy */
public $log;
public function __construct()
{
$this->log = new CoreLibs\Debug\Logging([
$this->log = new CoreLibs\Debug\LoggingLegacy([
'log_folder' => '../log/',
'file_id' => 'DebugTestTestLLogger',
]);
@@ -186,9 +212,9 @@ print "CLASS EXTEND: PRINTERRORMSG: <br>" . $tr->log->printErrorMsg() . "<br>";
// @codingStandardsIgnoreLine
class AttachOutside
{
/** @var \CoreLibs\Debug\Logging */
/** @var \CoreLibs\Debug\LoggingLegacy */
public $log;
public function __construct(\CoreLibs\Debug\Logging $logger_class)
public function __construct(\CoreLibs\Debug\LoggingLegacy $logger_class)
{
$this->log = $logger_class;
}
@@ -222,6 +248,12 @@ $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