DBG
in package
Debugging
Tags
Table of Contents
Constants
- DBG_PROFILE_LOG_DELTA_THRESHOLD = 0.2
- Threshold in seconds that will cause {@see DBG::time()} to dump a stack trace when the time delta between two log entries breaches.
Properties
- $builtinClasses : mixed
- List of classes defined by PHP
- $builtinInterfaces : mixed
- List of interfaces defined by PHP
- $enable_profiling : mixed
- $finishLineWriteRegistered : bool
- Tracks if the 'Request parsing completed'-log job has been registered already. If so, then register_shutdown_function() will not be called multiple times.
- $logHash : mixed
- $logPrefix : mixed
- $dbg_fh : mixed
- $enable_debug : mixed
- $enable_dump : mixed
- $enable_msg : mixed
- $enable_time : mixed
- $enable_trace : mixed
- $fileskiplength : mixed
- $firephp : mixed
- $last_time : mixed
- $log_adodb : mixed
- $log_file : mixed
- $log_firephp : mixed
- $log_memory : mixed
- $log_php : mixed
- $memory_logs : mixed
- $mode : mixed
- $sql_query_cache : mixed
- $start_time : mixed
Methods
- __construct() : mixed
- __internal__setup() : mixed
- Set up debugging
- _cleanfile() : mixed
- activate() : mixed
- Activates debugging according to the bits given in $mode
- activateIf() : mixed
- appendLogs() : mixed
- calltrace() : mixed
- deactivate() : mixed
- Deactivates debugging according to the bits given in $mode
- debug() : mixed
- disable_adodb_debug() : mixed
- disable_all() : mixed
- disable_debug() : mixed
- disable_dump() : mixed
- disable_error_reporting() : mixed
- disable_msg() : mixed
- disable_time() : mixed
- disable_trace() : mixed
- dump() : mixed
- Dump content of $val into the log.
- enable_adodb() : mixed
- enable_adodb_debug() : mixed
- enable_all() : mixed
- enable_debug() : mixed
- enable_dump() : mixed
- enable_error_reporting() : mixed
- enable_msg() : mixed
- enable_time() : mixed
- enable_trace() : mixed
- getActivatedFlagsAsString() : mixed
- getLoadedClasses() : array<string|int, mixed>
- Get a list of PHP classes that have been loaded until this point in time.
- getLoadedFiles() : array<string|int, mixed>
- Get a list of PHP files that have been loaded until this point in time.
- getLoadedInterfaces() : array<string|int, mixed>
- Get a list of PHP interfaces that have been loaded until this point in time.
- getLogHash() : mixed
- getMemoryLogs() : mixed
- getMode() : int
- Returns the current debugging mode bits
- getSQLQueryCache() : mixed
- hasCookie() : mixed
- hasCookieValue() : mixed
- init() : void
- Will enable debugging as defined by the environment variable `CLX_DBG_FLAGS`.
- isIp() : mixed
- log() : mixed
- logSQL() : mixed
- msg() : mixed
- phpErrorHandler() : mixed
- This method is only used if logging to a file
- resetLogPrefix() : mixed
- Reset the text that is being put in front of log messags
- set_adodb_debug_mode() : mixed
- setLogPrefix() : mixed
- Set a text that will be put in front of all log messages
- setSQLQueryCache() : mixed
- setup() : bool
- Sets up logging to a file
- stack() : mixed
- Dump a stack trace into the log.
- time() : void
- Wrapper for {@see static::log_time()} by setting $logIsAfterCall to false.
- trace() : mixed
- writeFinishLine() : mixed
- Writes the last line of a request to the log
- date() : string
- Get current UTC datetime formatted as $format
- disable_profiling() : mixed
- Disables profiling
- enable_profiling() : mixed
- Enable profiling
- log_time() : void
- If mode {@see static::DBG_PROFILE} has been enabled, then this generates a log entry that contains the current time, as well as the time that has been passed since: 1. the last log entry was generated 2. and script initialization Further, the generated log entry will contain the caller of this call.
- _escapeDoctrineDump() : mixed
- _log() : mixed
- disable_file() : mixed
- Disables logging to a file
- disable_firephp() : mixed
- Disables logging to FirePHP
- disable_memory() : mixed
- Disables logging to memory
- enable_file() : mixed
- Enables logging to a file
- enable_firephp() : mixed
- Enables logging to FirePHP
- enable_memory() : mixed
- Enables logging to memory
Constants
DBG_PROFILE_LOG_DELTA_THRESHOLD
Threshold in seconds that will cause {@see DBG::time()} to dump a stack trace when the time delta between two log entries breaches.
public
mixed
DBG_PROFILE_LOG_DELTA_THRESHOLD
= 0.2
Properties
$builtinClasses
List of classes defined by PHP
protected
static mixed
$builtinClasses
= []
$builtinInterfaces
List of interfaces defined by PHP
protected
static mixed
$builtinInterfaces
= []
$enable_profiling
protected
static mixed
$enable_profiling
= 0
$finishLineWriteRegistered
Tracks if the 'Request parsing completed'-log job has been registered already. If so, then register_shutdown_function() will not be called multiple times.
protected
static bool
$finishLineWriteRegistered
= \false
$logHash
protected
static mixed
$logHash
= ''
$logPrefix
protected
static mixed
$logPrefix
= ''
$dbg_fh
private
static mixed
$dbg_fh
= \null
$enable_debug
private
static mixed
$enable_debug
= \false
$enable_dump
private
static mixed
$enable_dump
= \null
$enable_msg
private
static mixed
$enable_msg
= \null
$enable_time
private
static mixed
$enable_time
= \null
$enable_trace
private
static mixed
$enable_trace
= \null
$fileskiplength
private
static mixed
$fileskiplength
= 0
$firephp
private
static mixed
$firephp
= \null
$last_time
private
static mixed
$last_time
= \null
$log_adodb
private
static mixed
$log_adodb
= \null
$log_file
private
static mixed
$log_file
= \null
$log_firephp
private
static mixed
$log_firephp
= \null
$log_memory
private
static mixed
$log_memory
= \null
$log_php
private
static mixed
$log_php
= 0
$memory_logs
private
static mixed
$memory_logs
= array()
$mode
private
static mixed
$mode
= 0
$sql_query_cache
private
static mixed
$sql_query_cache
= \null
$start_time
private
static mixed
$start_time
= \null
Methods
__construct()
public
__construct() : mixed
__internal__setup()
Set up debugging
public
static __internal__setup() : mixed
Called by both activate() and deactivate()
_cleanfile()
public
static _cleanfile(mixed $f) : mixed
Parameters
- $f : mixed
activate()
Activates debugging according to the bits given in $mode
public
static activate([int $mode = null ]) : mixed
See the constants defined early in this file. An empty $mode defaults to DBG_ALL & ~DBG_LOG_FILE & ~DBG_LOG_FIREPHP
Parameters
- $mode : int = null
-
The optional debugging mode bits
activateIf()
public
static activateIf(mixed $condition[, mixed $mode = null ]) : mixed
Parameters
- $condition : mixed
- $mode : mixed = null
appendLogs()
public
static appendLogs(mixed $logs) : mixed
Parameters
- $logs : mixed
calltrace()
public
static calltrace() : mixed
deactivate()
Deactivates debugging according to the bits given in $mode
public
static deactivate([int $mode = null ]) : mixed
See the constants defined early in this file. An empty $mode defaults to DBG_ALL, thus disabling debugging completely
Parameters
- $mode : int = null
-
The optional debugging mode bits
debug()
public
static debug(mixed $message) : mixed
Parameters
- $message : mixed
disable_adodb_debug()
public
static disable_adodb_debug() : mixed
disable_all()
public
static disable_all() : mixed
disable_debug()
public
static disable_debug() : mixed
disable_dump()
public
static disable_dump() : mixed
disable_error_reporting()
public
static disable_error_reporting() : mixed
disable_msg()
public
static disable_msg() : mixed
disable_time()
public
static disable_time() : mixed
disable_trace()
public
static disable_trace() : mixed
dump()
Dump content of $val into the log.
public
static dump(mixed $val[, int $modeConstrain = DBG_LOG ]) : mixed
Parameters
- $val : mixed
- $modeConstrain : int = DBG_LOG
-
Set to any of the available DBG basic flags to constrain the execution of the method to a specific DBG mode.
enable_adodb()
public
static enable_adodb() : mixed
enable_adodb_debug()
public
static enable_adodb_debug([mixed $flagTrace = false ]) : mixed
Parameters
- $flagTrace : mixed = false
enable_all()
public
static enable_all() : mixed
enable_debug()
public
static enable_debug() : mixed
enable_dump()
public
static enable_dump() : mixed
enable_error_reporting()
public
static enable_error_reporting() : mixed
enable_msg()
public
static enable_msg() : mixed
enable_time()
public
static enable_time() : mixed
enable_trace()
public
static enable_trace() : mixed
getActivatedFlagsAsString()
public
static getActivatedFlagsAsString() : mixed
getLoadedClasses()
Get a list of PHP classes that have been loaded until this point in time.
public
static getLoadedClasses([bool $native = false ][, bool $sort = false ]) : array<string|int, mixed>
Parameters
- $native : bool = false
-
Set to
true
to also include PHP's native classes. - $sort : bool = false
-
Set to
true
to return the list in alphabetical order.
Return values
array<string|int, mixed> —List of loaded classes until now.
getLoadedFiles()
Get a list of PHP files that have been loaded until this point in time.
public
static getLoadedFiles() : array<string|int, mixed>
Return values
array<string|int, mixed> —List of loaded PHP files until now listed in alphabetical order.
getLoadedInterfaces()
Get a list of PHP interfaces that have been loaded until this point in time.
public
static getLoadedInterfaces([bool $native = false ][, bool $sort = false ]) : array<string|int, mixed>
Parameters
- $native : bool = false
-
Set to
true
to also include PHP's native interfaces. - $sort : bool = false
-
Set to
true
to return the list in alphabetical order.
Return values
array<string|int, mixed> —List of loaded interfaces until now.
getLogHash()
public
static getLogHash() : mixed
getMemoryLogs()
public
static getMemoryLogs() : mixed
getMode()
Returns the current debugging mode bits
public
static getMode() : int
Return values
int —The debugging mode bits
getSQLQueryCache()
public
static getSQLQueryCache() : mixed
hasCookie()
public
static hasCookie(mixed $cookieName) : mixed
Parameters
- $cookieName : mixed
hasCookieValue()
public
static hasCookieValue(mixed $cookieName, mixed $cookieValue) : mixed
Parameters
- $cookieName : mixed
- $cookieValue : mixed
init()
Will enable debugging as defined by the environment variable `CLX_DBG_FLAGS`.
public
static init() : void
If variable is not set or value of CLX_DBG_FLAGS
translates into no valid mode,
then debugging will be disabled.
Set CLX_DBG_FLAGS
the same way as you would in PHP - as a pipe delimited
string of the desired DBG_*
mode constants. However the whole value must
be enclosed by quotes. I.e.: CLX_DBG_FLAGS='DBG_PHP | DBG_LOG_FILE'
isIp()
public
static isIp(mixed $ip) : mixed
Parameters
- $ip : mixed
log()
public
static log(mixed $text[, mixed $firephp_action = 'log' ][, mixed $additional_args = null ]) : mixed
Parameters
- $text : mixed
- $firephp_action : mixed = 'log'
- $additional_args : mixed = null
logSQL()
public
static logSQL(mixed $sql[, mixed $forceOutput = false ]) : mixed
Parameters
- $sql : mixed
- $forceOutput : mixed = false
msg()
public
static msg(mixed $message) : mixed
Parameters
- $message : mixed
phpErrorHandler()
This method is only used if logging to a file
public
static phpErrorHandler(unknown_type $errno, unknown_type $errstr, unknown_type $errfile, unknown_type $errline) : mixed
Parameters
- $errno : unknown_type
- $errstr : unknown_type
- $errfile : unknown_type
- $errline : unknown_type
resetLogPrefix()
Reset the text that is being put in front of log messags
public
static resetLogPrefix() : mixed
set_adodb_debug_mode()
public
static set_adodb_debug_mode() : mixed
setLogPrefix()
Set a text that will be put in front of all log messages
public
static setLogPrefix([string $prefix = '' ]) : mixed
Parameters
- $prefix : string = ''
-
The text that shall be put in front of log messages
setSQLQueryCache()
public
static setSQLQueryCache(mixed $msg) : mixed
Parameters
- $msg : mixed
setup()
Sets up logging to a file
public
static setup(string $file[, string $mode = 'a' ]) : bool
On each successive call, this will close the current log file handle if already open. If logging to FirePHP is enabled, it will then return true. Otherwise, the log file will be opened using the current parameter values
Parameters
- $file : string
-
The file name
- $mode : string = 'a'
-
The access mode (as with fopen())
Tags
Return values
bool —True
stack()
Dump a stack trace into the log.
public
static stack([int $modeConstrain = DBG_LOG ]) : mixed
Parameters
- $modeConstrain : int = DBG_LOG
-
Set to any of the available DBG basic flags to constrain the execution of the method to a specific DBG mode. Note that tracing (static::enable_trace()) must have been enabled too.
time()
Wrapper for {@see static::log_time()} by setting $logIsAfterCall to false.
public
static time([string $comment = '' ]) : void
Parameters
- $comment : string = ''
-
Optional message to append to log entry.
trace()
public
static trace([mixed $level = 0 ]) : mixed
Parameters
- $level : mixed = 0
writeFinishLine()
Writes the last line of a request to the log
public
static writeFinishLine(Cx $cx, bool $cached[, string $outputModule = null ]) : mixed
Parameters
- $cx : Cx
-
Cx instance of the request
- $cached : bool
-
Whether this request is answered from cache
- $outputModule : string = null
-
(optional) Name of the output module
date()
Get current UTC datetime formatted as $format
protected
static date(string $format) : string
Parameters
- $format : string
-
Format to return the current datetime back
Return values
string —Current datetime formated as $format.
disable_profiling()
Disables profiling
protected
static disable_profiling() : mixed
enable_profiling()
Enable profiling
protected
static enable_profiling() : mixed
log_time()
If mode {@see static::DBG_PROFILE} has been enabled, then this generates a log entry that contains the current time, as well as the time that has been passed since: 1. the last log entry was generated 2. and script initialization Further, the generated log entry will contain the caller of this call.
protected
static log_time([bool $logIsAfterCall = true ][, string $comment = '' ]) : void
Callers from filesystem (FileSystem and database layers (AdoDB and Doctrine) will not be logged, but instead their callers. If the delta to the last generated log entry is greater than static::DBG_PROFILE_LOG_DELTA_THRESHOLD and mode static::DBG_DEBUG is enabled, then a stacktrace static::stack() is dumped. If mode static::DBG_PROFILE is not set, then this is a no-op.
Parameters
- $logIsAfterCall : bool = true
-
Set to
true
if this call is called after a reference call. If set, then this will generate a log entry starting withTIME AFTER
. If set tofalse
, the log entry will start withTIME AT
. - $comment : string = ''
-
Optional message to append to log entry.
_escapeDoctrineDump()
private
static _escapeDoctrineDump(mixed &$val) : mixed
Parameters
- $val : mixed
_log()
private
static _log(mixed $text[, mixed $firephp_action = 'log' ][, mixed $additional_args = null ][, mixed $profile = true ]) : mixed
Parameters
- $text : mixed
- $firephp_action : mixed = 'log'
- $additional_args : mixed = null
- $profile : mixed = true
disable_file()
Disables logging to a file
private
static disable_file() : mixed
disable_firephp()
Disables logging to FirePHP
private
static disable_firephp() : mixed
disable_memory()
Disables logging to memory
private
static disable_memory() : mixed
enable_file()
Enables logging to a file
private
static enable_file() : mixed
Disables logging to FirePHP & memory in turn.
enable_firephp()
Enables logging to FirePHP
private
static enable_firephp() : mixed
Disables logging to a file in turn.
enable_memory()
Enables logging to memory
private
static enable_memory() : mixed
Disables logging to a file and firephp in turn.