Add print bool in logging class
This commit is contained in:
@@ -8,6 +8,9 @@ for file in $(ls -1 ${base_folder}../4dev/locale/*.po); do
|
|||||||
echo "Translate language ${file}";
|
echo "Translate language ${file}";
|
||||||
locale=$(echo "${file}" | cut -d "-" -f 1);
|
locale=$(echo "${file}" | cut -d "-" -f 1);
|
||||||
domain=$(echo "${file}" | cut -d "-" -f 2);
|
domain=$(echo "${file}" | cut -d "-" -f 2);
|
||||||
|
if [ ! -d "${base_folder}/includes/locale/${locale}/LC_MESSAGES/" ]; then
|
||||||
|
mkdir -p "${base_folder}/includes/locale/${locale}/LC_MESSAGES/";
|
||||||
|
fi;
|
||||||
msgfmt -o ${base_folder}/includes/locale/${locale}/LC_MESSAGES/${domain}.mo ${base_folder}../4dev/locale/${locale}-${domain}.po;
|
msgfmt -o ${base_folder}/includes/locale/${locale}/LC_MESSAGES/${domain}.mo ${base_folder}../4dev/locale/${locale}-${domain}.po;
|
||||||
done;
|
done;
|
||||||
|
|
||||||
|
|||||||
@@ -181,6 +181,10 @@ $debug->debug('TEST PER LEVEL', 'Per level test');
|
|||||||
$debug->debug('()', 'Per level test: invalid chars');
|
$debug->debug('()', 'Per level test: invalid chars');
|
||||||
$debug->setLogPer('level', false);
|
$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));
|
||||||
|
|
||||||
// error message
|
// error message
|
||||||
// future DEPRECATED
|
// future DEPRECATED
|
||||||
// $debug->debug('BASIC CLASS', 'Debug test');
|
// $debug->debug('BASIC CLASS', 'Debug test');
|
||||||
|
|||||||
@@ -19,15 +19,17 @@ if (!empty($DEBUG_ALL) && !empty($ENABLE_ERROR_HANDLING)) {
|
|||||||
//------------------------------ library include start
|
//------------------------------ library include start
|
||||||
// set output to quiet for load of classes & session settings
|
// set output to quiet for load of classes & session settings
|
||||||
ob_start();
|
ob_start();
|
||||||
// set the session name
|
|
||||||
$SET_SESSION_NAME = EDIT_SESSION_NAME;
|
|
||||||
$LOG_FILE_ID = BASE_NAME . 'Admin';
|
|
||||||
//------------------------------ library include end
|
//------------------------------ library include end
|
||||||
|
|
||||||
//------------------------------ basic variable settings start
|
//------------------------------ basic variable settings start
|
||||||
|
// set the session name
|
||||||
|
$SET_SESSION_NAME = EDIT_SESSION_NAME;
|
||||||
|
$LOG_FILE_ID = BASE_NAME . 'Admin';
|
||||||
|
// ajax page flag
|
||||||
if (!isset($AJAX_PAGE)) {
|
if (!isset($AJAX_PAGE)) {
|
||||||
$AJAX_PAGE = false;
|
$AJAX_PAGE = false;
|
||||||
}
|
}
|
||||||
|
// zip download flag
|
||||||
if (!isset($ZIP_STREAM)) {
|
if (!isset($ZIP_STREAM)) {
|
||||||
$ZIP_STREAM = false;
|
$ZIP_STREAM = false;
|
||||||
}
|
}
|
||||||
@@ -48,7 +50,7 @@ if ($AJAX_PAGE && !$ZIP_STREAM) {
|
|||||||
// start session
|
// start session
|
||||||
$session = new \CoreLibs\Create\Session($SET_SESSION_NAME);
|
$session = new \CoreLibs\Create\Session($SET_SESSION_NAME);
|
||||||
// create logger
|
// create logger
|
||||||
$log = new CoreLibs\Debug\Logging([
|
$log = new \CoreLibs\Debug\Logging([
|
||||||
'log_folder' => BASE . LOG,
|
'log_folder' => BASE . LOG,
|
||||||
'file_id' => $LOG_FILE_ID,
|
'file_id' => $LOG_FILE_ID,
|
||||||
'print_file_date' => true,
|
'print_file_date' => true,
|
||||||
@@ -69,9 +71,9 @@ if (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// db config with logger
|
// db config with logger
|
||||||
$db = new CoreLibs\DB\IO(DB_CONFIG, $log);
|
$db = new \CoreLibs\DB\IO(DB_CONFIG, $log);
|
||||||
// login & page access check
|
// login & page access check
|
||||||
$login = new CoreLibs\ACL\Login($db, $log, $session);
|
$login = new \CoreLibs\ACL\Login($db, $log, $session);
|
||||||
// lang, path, domain
|
// lang, path, domain
|
||||||
// pre auto detect language after login
|
// pre auto detect language after login
|
||||||
$locale = \CoreLibs\Language\GetLocale::setLocale();
|
$locale = \CoreLibs\Language\GetLocale::setLocale();
|
||||||
@@ -82,9 +84,9 @@ $l10n = new \CoreLibs\Language\L10n(
|
|||||||
$locale['path'],
|
$locale['path'],
|
||||||
);
|
);
|
||||||
// create smarty object
|
// create smarty object
|
||||||
$smarty = new CoreLibs\Template\SmartyExtend($l10n, $locale);
|
$smarty = new \CoreLibs\Template\SmartyExtend($l10n, $locale);
|
||||||
// create new Backend class with db and loger attached
|
// create new Backend class with db and loger attached
|
||||||
$cms = new CoreLibs\Admin\Backend($db, $log, $session, $l10n, $locale);
|
$cms = new \CoreLibs\Admin\Backend($db, $log, $session, $l10n, $locale);
|
||||||
// the menu show flag (what menu to show)
|
// the menu show flag (what menu to show)
|
||||||
$cms->menu_show_flag = 'main';
|
$cms->menu_show_flag = 'main';
|
||||||
// db info
|
// db info
|
||||||
|
|||||||
@@ -310,6 +310,7 @@ class Logging
|
|||||||
* Needs debug/echo/print ad target for which of the debug flag groups we check
|
* Needs debug/echo/print ad target for which of the debug flag groups we check
|
||||||
* also needs level string to check in the per level output flag check.
|
* also needs level string to check in the per level output flag check.
|
||||||
* In case we have invalid target it will return false
|
* In case we have invalid target it will return false
|
||||||
|
*
|
||||||
* @param string $target target group to check debug/echo/print
|
* @param string $target target group to check debug/echo/print
|
||||||
* @param string $level level to check in detailed level flag
|
* @param string $level level to check in detailed level flag
|
||||||
* @return bool true on access allowed or false on no access
|
* @return bool true on access allowed or false on no access
|
||||||
@@ -332,6 +333,7 @@ class Logging
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* writes error msg data to file for current level
|
* writes error msg data to file for current level
|
||||||
|
*
|
||||||
* @param string $level the level to write
|
* @param string $level the level to write
|
||||||
* @param string $error_string error string to write
|
* @param string $error_string error string to write
|
||||||
* @return bool True if message written, FAlse if not
|
* @return bool True if message written, FAlse if not
|
||||||
@@ -412,6 +414,7 @@ class Logging
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Temporary method to read all class variables for testing purpose
|
* Temporary method to read all class variables for testing purpose
|
||||||
|
*
|
||||||
* @param string $name what variable to return
|
* @param string $name what variable to return
|
||||||
* @return mixed can be anything, bool, string, int, array
|
* @return mixed can be anything, bool, string, int, array
|
||||||
*/
|
*/
|
||||||
@@ -425,6 +428,7 @@ class Logging
|
|||||||
* sets the internal log file prefix id
|
* sets the internal log file prefix id
|
||||||
* string must be a alphanumeric string
|
* string must be a alphanumeric string
|
||||||
* if non valid string is given it returns the previous set one only
|
* if non valid string is given it returns the previous set one only
|
||||||
|
*
|
||||||
* @param string $string log file id string value
|
* @param string $string log file id string value
|
||||||
* @return string returns the set log file id string
|
* @return string returns the set log file id string
|
||||||
* @deprecated Use $log->setLogId()
|
* @deprecated Use $log->setLogId()
|
||||||
@@ -438,6 +442,7 @@ class Logging
|
|||||||
* sets the internal log file prefix id
|
* sets the internal log file prefix id
|
||||||
* string must be a alphanumeric string
|
* string must be a alphanumeric string
|
||||||
* if non valid string is given it returns the previous set one only
|
* if non valid string is given it returns the previous set one only
|
||||||
|
*
|
||||||
* @param string $string log file id string value
|
* @param string $string log file id string value
|
||||||
* @return string returns the set log file id string
|
* @return string returns the set log file id string
|
||||||
*/
|
*/
|
||||||
@@ -460,6 +465,7 @@ class Logging
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* old name for setLogLevel
|
* old name for setLogLevel
|
||||||
|
*
|
||||||
* @param string $type debug, echo, print
|
* @param string $type debug, echo, print
|
||||||
* @param string $flag on/off
|
* @param string $flag on/off
|
||||||
* array $array of levels to turn on/off debug
|
* array $array of levels to turn on/off debug
|
||||||
@@ -475,6 +481,7 @@ class Logging
|
|||||||
/**
|
/**
|
||||||
* set log level settings for All types
|
* set log level settings for All types
|
||||||
* if invalid type, skip
|
* if invalid type, skip
|
||||||
|
*
|
||||||
* @param string $type Type to get: debug, echo, print
|
* @param string $type Type to get: debug, echo, print
|
||||||
* @param bool $set True or False
|
* @param bool $set True or False
|
||||||
* @return bool Return false if type invalid
|
* @return bool Return false if type invalid
|
||||||
@@ -491,6 +498,7 @@ class Logging
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* get the current log level setting for All level blocks
|
* get the current log level setting for All level blocks
|
||||||
|
*
|
||||||
* @param string $type Type to get: debug, echo, print
|
* @param string $type Type to get: debug, echo, print
|
||||||
* @return bool False on failure, or the boolean flag from the all var
|
* @return bool False on failure, or the boolean flag from the all var
|
||||||
*/
|
*/
|
||||||
@@ -506,6 +514,7 @@ class Logging
|
|||||||
/**
|
/**
|
||||||
* passes list of level names, to turn on debug
|
* passes list of level names, to turn on debug
|
||||||
* eg $foo->debugFor('print', 'on', ['LOG', 'DEBUG', 'INFO']);
|
* eg $foo->debugFor('print', 'on', ['LOG', 'DEBUG', 'INFO']);
|
||||||
|
*
|
||||||
* @param string $type debug, echo, print
|
* @param string $type debug, echo, print
|
||||||
* @param string $flag on/off
|
* @param string $flag on/off
|
||||||
* @param array<mixed> $debug_on Array of levels to turn on/off debug
|
* @param array<mixed> $debug_on Array of levels to turn on/off debug
|
||||||
@@ -541,6 +550,7 @@ class Logging
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* return the log level for the array type normal and not (disable)
|
* return the log level for the array type normal and not (disable)
|
||||||
|
*
|
||||||
* @param string $type debug, echo, print
|
* @param string $type debug, echo, print
|
||||||
* @param string $flag on/off
|
* @param string $flag on/off
|
||||||
* @param string|null $level if not null then check if this array entry is set
|
* @param string|null $level if not null then check if this array entry is set
|
||||||
@@ -572,6 +582,7 @@ class Logging
|
|||||||
* - class: split by class
|
* - class: split by class
|
||||||
* - page: split per page called
|
* - page: split per page called
|
||||||
* - run: for each run
|
* - run: for each run
|
||||||
|
*
|
||||||
* @param string $type Type to get: level, class, page, run
|
* @param string $type Type to get: level, class, page, run
|
||||||
* @param bool $set True or False
|
* @param bool $set True or False
|
||||||
* @return bool Return false if type invalid
|
* @return bool Return false if type invalid
|
||||||
@@ -587,6 +598,7 @@ class Logging
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* return current set log per flag in bool
|
* return current set log per flag in bool
|
||||||
|
*
|
||||||
* @param string $type Type to get: level, class, page, run
|
* @param string $type Type to get: level, class, page, run
|
||||||
* @return bool True of false for turned on or off
|
* @return bool True of false for turned on or off
|
||||||
*/
|
*/
|
||||||
@@ -601,6 +613,7 @@ class Logging
|
|||||||
/**
|
/**
|
||||||
* Set or get the log file date extension flag
|
* Set or get the log file date extension flag
|
||||||
* if null or empty parameter gets current flag
|
* if null or empty parameter gets current flag
|
||||||
|
*
|
||||||
* @param boolean|null $set Set the date suffix for log files
|
* @param boolean|null $set Set the date suffix for log files
|
||||||
* If set to null return current set
|
* If set to null return current set
|
||||||
* @return boolean Current set flag
|
* @return boolean Current set flag
|
||||||
@@ -615,6 +628,7 @@ class Logging
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return current set log file name
|
* Return current set log file name
|
||||||
|
*
|
||||||
* @return string Filename set set after the last time debug was called
|
* @return string Filename set set after the last time debug was called
|
||||||
*/
|
*/
|
||||||
public function getLogFileName(): string
|
public function getLogFileName(): string
|
||||||
@@ -628,6 +642,7 @@ class Logging
|
|||||||
* It uses some special code sets so we can convert that to pre flags
|
* It uses some special code sets so we can convert that to pre flags
|
||||||
* for echo output {##HTMLPRE##} ... {##/HTMLPRE##}
|
* for echo output {##HTMLPRE##} ... {##/HTMLPRE##}
|
||||||
* Do not use this without using it in a string in debug function
|
* Do not use this without using it in a string in debug function
|
||||||
|
*
|
||||||
* @param array<mixed> $a Array to format
|
* @param array<mixed> $a Array to format
|
||||||
* @return string print_r formated
|
* @return string print_r formated
|
||||||
*/
|
*/
|
||||||
@@ -636,14 +651,32 @@ class Logging
|
|||||||
return '##HTMLPRE##' . print_r($a, true) . '##/HTMLPRE##';
|
return '##HTMLPRE##' . print_r($a, true) . '##/HTMLPRE##';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert bool value to string value
|
||||||
|
*
|
||||||
|
* @param bool $bool Bool value to be transformed
|
||||||
|
* @param string $true Override default string 'true'
|
||||||
|
* @param string $false Override default string 'false'
|
||||||
|
* @return string $true or $false string for true/false bool
|
||||||
|
*/
|
||||||
|
public function prBl(
|
||||||
|
bool $bool,
|
||||||
|
string $true = 'true',
|
||||||
|
string $false = 'false'
|
||||||
|
): string {
|
||||||
|
return $bool ? $true : $false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* write debug data to error_msg array
|
* write debug data to error_msg array
|
||||||
|
*
|
||||||
* @param string $level id for error message, groups messages together
|
* @param string $level id for error message, groups messages together
|
||||||
* @param string $string the actual error message
|
* @param string $string the actual error message
|
||||||
* @param bool $strip default on false, if set to true,
|
* @param bool $strip default on false, if set to true,
|
||||||
* all html tags will be stripped and <br> changed to \n
|
* all html tags will be stripped and <br> changed to \n
|
||||||
* this is only used for debug output
|
* this is only used for debug output
|
||||||
* @param string $prefix Attach some block before $string. Will not be stripped even
|
* @param string $prefix Attach some block before $string.
|
||||||
|
* Will not be stripped even
|
||||||
* when strip is true
|
* when strip is true
|
||||||
* if strip is false, recommended to add that to $string
|
* if strip is false, recommended to add that to $string
|
||||||
* @return bool True if logged, false if not logged
|
* @return bool True if logged, false if not logged
|
||||||
@@ -729,6 +762,7 @@ class Logging
|
|||||||
/**
|
/**
|
||||||
* for ECHO ON only
|
* for ECHO ON only
|
||||||
* returns error data as string so it can be echoed out
|
* returns error data as string so it can be echoed out
|
||||||
|
*
|
||||||
* @param string $header_prefix prefix string for header
|
* @param string $header_prefix prefix string for header
|
||||||
* @return string error msg for all levels
|
* @return string error msg for all levels
|
||||||
*/
|
*/
|
||||||
@@ -780,6 +814,7 @@ class Logging
|
|||||||
* unsests the error message array
|
* unsests the error message array
|
||||||
* can be used if writing is primary to file
|
* can be used if writing is primary to file
|
||||||
* if no level given resets all
|
* if no level given resets all
|
||||||
|
*
|
||||||
* @param string $level optional level
|
* @param string $level optional level
|
||||||
* @return void has no return
|
* @return void has no return
|
||||||
*/
|
*/
|
||||||
@@ -795,6 +830,7 @@ class Logging
|
|||||||
/**
|
/**
|
||||||
* for ECHO ON only
|
* for ECHO ON only
|
||||||
* Get current error message array
|
* Get current error message array
|
||||||
|
*
|
||||||
* @return array<mixed> error messages collected
|
* @return array<mixed> error messages collected
|
||||||
*/
|
*/
|
||||||
public function getErrorMsg(): array
|
public function getErrorMsg(): array
|
||||||
@@ -806,6 +842,7 @@ class Logging
|
|||||||
* for ECHO ON only
|
* for ECHO ON only
|
||||||
* merges the given error array with the one from this class
|
* merges the given error array with the one from this class
|
||||||
* only merges visible ones
|
* only merges visible ones
|
||||||
|
*
|
||||||
* @param array<mixed> $error_msg error array
|
* @param array<mixed> $error_msg error array
|
||||||
* @return void has no return
|
* @return void has no return
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user