Class: Debug

Declaration class Debug
Datei class.debug.php
Date/Time modify File 2023-01-22 15:33:09
File-Size 35 KByte
MD5 File 853629328e4a94bfb912d8ef55fbe660
Version 2.52 (const VERSION = 2.52)
Date 2022-10-26

Public Methods

Methods and Parameter Description/Comments
public static function log($OnOff_or_File = true, $OnOff_err_log = null) start/stop logging display/logfile
log(false) : all methods will do nothing , System-Log unchanged
log("filename") : start and write debug-info into logfile
log("+filename") : start and write debug-info into logfile append
log("filename",true): start and write debug-info and system Warnings and Errors into logfile
log('') : stop logfile, next write will show on display
public static function catchError() aktivate catch Error and Exceptions
public static function save(/** $var1, $var2, .. **/) save the loginformation in a buffer or logfile, no output
$var1, $var2, .. **/
public static function write(/** $var1, $var2, .. **/) general output for saved and current debug-infos on display or logfile
$var1, $var2, .. **/
public static function writeIf($condition = null/** $var1, $var2, .. **/) general output for saved and current debug-infos on display or logfile
if $condition == true
if
$var1, $var2, .. **/
public static function wrc(/** $var1, $var2, .. **/) write with color red
$var1, $var2, .. **/
public static function writePre(/** $var1, $var2, .. **/) general output for saved and current debug-infos on display or logfile
display text in <pre>-tags
$var1, $var2, .. **/
public static function writeHex(/** $var1, $var2, .. **/) display strings as hex
$var1, $var2, .. **/
public static function writeUni(/** $var1, $var2, .. **/) display strings with unicode characters as \u{fc}
$var1, $var2, .. **/
public static function html(/** $var1, $var2, .. **/) get the loginformation from buffer and delete buffer
return html-table (up to V1.95 getClean() )
$var1, $var2, .. **/
public static function stop($condition = null /**, $var1, $var2, .. **/) general output like write a output for saved and actual debug-infos on display or logfile
$condition : if condition ist true or null then write and throw a exception, in the other case do nothing
if $condition is int, write and stop at the $condition call
if $condition is int and 0 or <0 do nothing (also no decrement stopCounter)
, $var1, $var2, .. **/
public static function resetStopCounter() Reset for Stop Counter
public static function clear() clear internal buffer, deletes all information that have been saved
logfile-infos not delete
public static function systeminfo() Info
public static function crc($value) Returns the 32-bit CRC checksum of the argument as a hex string of length 8
accept int, float, string, arrays and objects, no resource
public static function microSleep($microSeconds) sleep $microSeconds, return real count microseconds
public static function TypeInfo($obj, $options = array()) TypeInfo returns a string type of (len,class,resource-typ..)
public static function strhex($s) return a string as hexadecimal like '\x61\x62..'
public static function UniDecode($strUplus) return char for Unicode-Format U+20ac (U+0000..U+3FFF)
false if error
public static function strToUnicode($string) return PHP unicode string Format '\u{20ac}\A' for all multibyte chars of string
for non utf8 chars returns "\xhh"
public static function firstChar($string) get first utf-8 multibyte char or first byte
@param string input: valid or invalid utf-8 string
@return string, bool false if error (for string = "")
public static function unicodeToString($string) convert a string with unicode \u{30} or hex code \x30 to string
@param string $string
@return string
example: debug::unicodeToString("a\x42\u{e4}\u{20ac}") -> "aBä€"
public static function detect_encoding($string) tries to determine the charset of string
return p.E. 'UTF-8','UTF-8 BOM','ISO-8859-1','ASCII'
faster as mb_detect_encoding($string,'ASCII, UTF-8, ISO-8859-1',true);
public static function setTitleColor($backgroundColor) set a new color for background of title
public static function setImgStyle($style) set style for gd-resource
public static function setGdOutputFormat($Ident) set $gdOutputFormat
param Ident : "png" or "jpg"
public static function switchLog($filePath = NULL) Activate the log depending on the contents of the file
If content "1" Log is enabled, else if content "0" disabled
If param is bool, permanent activ/deaktive with true/false
Default filePath: __DIR__.'/debug.switch'
public static function deleteLogFile() Delete a Logfile set with debug::log("filename")
debug::write after deleteLogFile will display on screen
public static function deleteLastLogFileSegment() Delete last Segment from Logfile
@return bool true if logfile cut, false if not
public static function getLogFileName() get the current LogFileName
public static function isOn() return true if debug mode is on
public static function setTimestamp($index = 0) Start stopwatch
public static function getTimestampDiff($index = 0) get Time in µs from start stowatch to now
return int time µs or false if index not valid
public static function headerInfo() get Infos for headers sent
return array (
'headerSent' => false,
'fileName' => "",
'line' => 0,
'output_buffering' => "",
'bytes output buffer' => false,
)
public static function isHeaderSent() is header sent
public static function getErrorTypName($type) Get a Name for Error-Type
@param int $type
@return string
public static function shutDownHandle($flag = false)
public static function detectUTFencoding($string, $checkLen = 64) detect UTF encodings
@param string $string
@param int $checkLen : uses a maximum of checkLen bytes for analysis
@return string : UTF-8, UTF-8_BOM, UTF-16, UTF-16_BOM
UTF-32, UTF-32_BOM, Other

Public Propertys

Property and Defaults Description/Comments
public static $showSpecialChars = true; convert special chars in hex-code
public static $real_time_output = false; shows the debug info promptly
public static $exitOnStop = true; if $exitOnStop is true, stop method make a exit after output
if $exitOnStop is false, stop method return true after output
public static $stringCut = 180; cut Strings with more than $stringCut chars and $showSpecialChars = true

Constants

Declaration/Name Value Description/Comments
const VERSION = "2.52"; '2.52'