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

@@ -6,11 +6,6 @@
declare(strict_types=1);
$DEBUG_ALL_OVERRIDE = false; // set to 1 to debug on live/remote server locations
$DEBUG_ALL = true;
$PRINT_ALL = true;
$DB_DEBUG = true;
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
ob_start();
@@ -23,17 +18,16 @@ require 'config.php';
$LOG_FILE_ID = 'classTest';
$SET_SESSION_NAME = EDIT_SESSION_NAME;
use CoreLibs\Logging;
use CoreLibs\Debug\Support;
// init login & backend class
$session = new CoreLibs\Create\Session($SET_SESSION_NAME);
$log = new CoreLibs\Debug\Logging([
$log = new Logging\Logging([
'log_folder' => BASE . LOG,
'file_id' => $LOG_FILE_ID,
'log_file_id' => $LOG_FILE_ID,
// add file date
'print_file_date' => true,
// set debug and print flags
'debug_all' => $DEBUG_ALL,
'echo_all' => $ECHO_ALL ?? false,
'print_all' => $PRINT_ALL,
'log_per_date' => true,
]);
$db = new CoreLibs\DB\IO(DB_CONFIG, $log);
$login = new CoreLibs\ACL\Login(
@@ -102,6 +96,7 @@ print '<div><a href="class_test.readenvfile.php">Class Test: READ ENV FILE</a></
print '<div><a href="class_test.runningtime.php">Class Test: RUNNING TIME</a></div>';
print '<div><a href="class_test.memoryusage.php">Class Test: MEMORY USAGE</a></div>';
print '<div><a href="class_test.debug.php">Class Test: DEBUG</a></div>';
print '<div><a href="class_test.logging.php">Class Test: LOGGING</a></div>';
print '<div><a href="class_test.output.form.php">Class Test: OUTPUT FORM</a></div>';
print '<div><a href="class_test.admin.backend.php">Class Test: BACKEND ADMIN CLASS</a></div>';
print '<div><a href="class_test.lang.php">Class Test: LANG/L10n</a></div>';
@@ -116,10 +111,10 @@ print '<div><a href="class_test.config.direct.php">Class Test: CONFIG DIRECT</a>
print '<div><a href="subfolder/class_test.config.direct.php">Class Test: CONFIG DIRECT SUB</a></div>';
print "<hr>";
print "L: " . CoreLibs\Debug\Support::printAr($locale) . "<br>";
print "L: " . Support::dumpVar($locale) . "<br>";
// print all _ENV vars set
print "<div>READ _ENV ARRAY:</div>";
print CoreLibs\Debug\Support::printAr(array_map('htmlentities', $_ENV));
print Support::dumpVar(array_map('htmlentities', $_ENV));
// set + check edit access id
$edit_access_id = 3;
if (is_object($login) && isset($login->loginGetAcl()['unit'])) {
@@ -134,7 +129,7 @@ if (is_object($login) && isset($login->loginGetAcl()['unit'])) {
print "Something went wrong with the login<br>";
}
// $backend->log->debug('SESSION', \CoreLibs\Debug\Support::printAr($_SESSION));
// $backend->log->debug('SESSION', \CoreLibs\Debug\Support::dumpVar($_SESSION));
print '<form method="post" name="loginlogout">';
print '<a href="javascript:document.loginlogout.login_logout.value=\'Logou\';'
@@ -142,18 +137,23 @@ print '<a href="javascript:document.loginlogout.login_logout.value=\'Logou\';'
print '<input type="hidden" name="login_logout" value="">';
print '</form>';
// print the debug core vars
foreach (['on', 'off'] as $flag) {
foreach (['debug', 'echo', 'print'] as $type) {
$prefix = $flag == 'off' ? 'NOT ' : '';
print $prefix . strtoupper($type) . ' OUT: '
. \CoreLibs\Debug\Support::printAr(\CoreLibs\Convert\SetVarType::setArray(
$backend->log->getLogLevel($type, $flag)
)) . '<br>';
}
}
foreach (['debug', 'echo', 'print'] as $type) {
print strtoupper($type) . ' OUT ALL: ' . $backend->log->getLogLevelAll($type) . '<br>';
print "Log Level: " . $backend->log->getLoggingLevel()->getName() . "<br>";
print "Log ID: " . $backend->log->getLogFileId() . "<br>";
print "Log Date: " . $backend->log->getLogDate() . "<br>";
print "Log Max File Size: " . $backend->log->getLogMaxFileSize() . " bytes<br>";
print "Log Flags: " . $backend->log->getLogFlags() . "<br>";
foreach (
[
Logging\Logger\Flag::per_run,
Logging\Logger\Flag::per_date,
Logging\Logger\Flag::per_group,
Logging\Logger\Flag::per_page,
Logging\Logger\Flag::per_class,
Logging\Logger\Flag::per_level
] as $flag
) {
print "Log Flag: " . $flag->name . ": "
. CoreLibs\Debug\Support::printBool($backend->log->getLogFlag($flag)) . "<br>";
}
$log->debug('SOME MARK', 'Some error output');
@@ -162,7 +162,7 @@ $log->debug('SOME MARK', 'Some error output');
print "EDIT ACCESS ID: " . $backend->edit_access_id . "<br>";
if (is_object($login)) {
// print "ACL: <br>".$backend->print_ar($login->loginGetAcl())."<br>";
$log->debug('ACL', "ACL: " . \CoreLibs\Debug\Support::printAr($login->loginGetAcl()));
$log->debug('ACL', "ACL: " . \CoreLibs\Debug\Support::dumpVar($login->loginGetAcl()));
// print "DEFAULT ACL: <br>".$backend->print_ar($login->default_acl_list)."<br>";
// print "DEFAULT ACL: <br>".$backend->print_ar($login->default_acl_list)."<br>";
// $result = array_flip(
@@ -184,15 +184,11 @@ print "THIS HOST: " . HOST_NAME . ", with PROTOCOL: " . HOST_PROTOCOL . " is run
print "DIR: " . DIR . "<br>";
print "BASE: " . BASE . "<br>";
print "ROOT: " . ROOT . "<br>";
print "HOST: " . HOST_NAME . " => DB HOST: " . DB_CONFIG_NAME . " => " . print_r(DB_CONFIG, true) . "<br>";
print "HOST: " . HOST_NAME . " => DB HOST: " . DB_CONFIG_NAME . " => " . Support::dumpVar(DB_CONFIG) . "<br>";
print "DS is: " . DIRECTORY_SEPARATOR . "<br>";
print "SERVER HOST: " . $_SERVER['HTTP_HOST'] . "<br>";
// print error messages
// print $login->log->printErrorMsg();
print $log->printErrorMsg();
print "</body></html>";
# __END__