Documentation

DBG
in package

Tags
copyright

Cloudrexx AG

author

Thomas Wirz thomas.wirz@cloudrexx.com

author

Michael Ritter michael.ritter@cloudrexx.com

author

David Vogt david.vogt@comvation.com

subpackage

lib_dbg

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.
FLAGS_LOG_PROFILING  = \DBG_PROFILE_ON | \DBG_PROFILE_OFF | \DBG_PROFILE_FORCE
Bitwise combination of all DBG_PROFILE_* flags supported by {@see DBG_Log} for controlling the profiling behaviour
FLAGS_LOG_STREAM_VERBOSITY  = \DBG::FLAGS_LOG_VERBOSITY | \DBG_PROFILE
Bitwise combination of all DBG_* flags supported by {@see DBG_LogStream} to set log verbosity
FLAGS_LOG_VERBOSITY  = \DBG_NONE | \DBG_LOG | \DBG_DEBUG | \DBG_PHP | \DBG_DB | \DBG_DB_TRACE | \DBG_DB_ERROR
Bitwise combination of all DBG_* flags supported by {@see DBG_Log} to set log verbosity
LOG_STREAM_NAME_CLI  = 'cli'
Name of the direct cli log stream
LOG_STREAM_NAME_DEFAULT  = 'dbg.log'
Name of the default log stream
LOG_STREAM_NAME_EXTENDED  = 'extended_dbg.log'
Name of the extended log stream
LOG_STREAM_NAME_MEMORY  = 'memory'
Name of the memory log stream

Properties

$builtinClasses  : mixed
List of classes defined by PHP
$builtinInterfaces  : mixed
List of interfaces defined by PHP
$fileskiplength  : 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.
$log_php  : mixed
$logHash  : mixed
$logPrefix  : mixed
$logStreams  : array<string|int, mixed>
List of registered log streams
$mode  : mixed
$startTime  : float
Time in microseconds of first log event

Methods

__construct()  : mixed
__internal__setup()  : void
Set up debugging
activate()  : void
Activates debugging according to the bits given in $mode
activateIf()  : void
appendLogs()  : void
appendLogsToStreams()  : void
Append logs to all registered log streams
calltrace()  : void
Log the script file position along with the caller to the current method
cleanfile()  : string
deactivate()  : void
Deactivates debugging according to the bits given in $mode
debug()  : void
deregisterLogStream()  : bool
Deregister a log stream
dump()  : void
Dump content of $val into the log.
dumpExtendedLog()  : void
Dump collected logs (by memory when using `DBG_LOG_MEMORY`) to extended log stream (`/tmp/log/extended_dbg.log`).
getActivatedFlagsAsString()  : string
Retrieve a string representation of activated flags
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()  : string
getLogPrefix()  : string
Get currently set log prefix
getLogsFromStream()  : array<string|int, mixed>
getMemoryLogs()  : array<string|int, mixed>
getMode()  : int
Returns the current debugging mode bits
getUsableFlags()  : array<string|int, mixed>
Get a list of all available DBG flags that can be used on {@see static::activate()} and related methods during runtime.
hasCookie()  : bool
hasCookieValue()  : bool
init()  : void
Will enable debugging as defined by the environment variable `CLX_DBG_FLAGS`.
isIp()  : bool
log()  : void
logSQL()  : void
msg()  : void
phpErrorHandler()  : void
This method is only used if logging to a file
registerLogStream()  : bool
Register a stream to send logs to
resetLogPrefix()  : void
Reset the text that is being put in front of log messags
setLogPrefix()  : void
Set a text that will be put in front of all log messages
stack()  : void
Dump a stack trace into the log.
time()  : void
Wrapper for {@see static::log_time()} by setting $logIsAfterCall to false.
trace()  : void
Log the current script file position or a specific step from the stack- trace by setting `$level` to the desired level.
writeFinishLine()  : void
Writes the last line of a request to the log
_escapeDoctrineDump()  : void
_log()  : void
disable_error_reporting()  : void
disable_file()  : void
Disables logging to a file
disable_memory()  : void
Disables logging to memory
enable_error_reporting()  : void
enable_file()  : void
Enables logging to a file
enable_memory()  : void
Enables logging to memory
enableCliOutput()  : void
Register a log stream to output to stdout
enableExtendedLog()  : bool
Enable extended log stream (`/tmp/log/extended_dbg.log`)
getLogStoragePath()  : string

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

FLAGS_LOG_PROFILING

Bitwise combination of all DBG_PROFILE_* flags supported by {@see DBG_Log} for controlling the profiling behaviour

public int FLAGS_LOG_PROFILING = \DBG_PROFILE_ON | \DBG_PROFILE_OFF | \DBG_PROFILE_FORCE

FLAGS_LOG_STREAM_VERBOSITY

Bitwise combination of all DBG_* flags supported by {@see DBG_LogStream} to set log verbosity

public int FLAGS_LOG_STREAM_VERBOSITY = \DBG::FLAGS_LOG_VERBOSITY | \DBG_PROFILE
Tags
todo

This should be split up into two constants. One for log verbosity and one for profiling setup.

FLAGS_LOG_VERBOSITY

Bitwise combination of all DBG_* flags supported by {@see DBG_Log} to set log verbosity

public int FLAGS_LOG_VERBOSITY = \DBG_NONE | \DBG_LOG | \DBG_DEBUG | \DBG_PHP | \DBG_DB | \DBG_DB_TRACE | \DBG_DB_ERROR

LOG_STREAM_NAME_CLI

Name of the direct cli log stream

protected string LOG_STREAM_NAME_CLI = 'cli'

LOG_STREAM_NAME_DEFAULT

Name of the default log stream

protected string LOG_STREAM_NAME_DEFAULT = 'dbg.log'

LOG_STREAM_NAME_EXTENDED

Name of the extended log stream

protected string LOG_STREAM_NAME_EXTENDED = 'extended_dbg.log'

LOG_STREAM_NAME_MEMORY

Name of the memory log stream

protected string LOG_STREAM_NAME_MEMORY = 'memory'

Properties

$builtinClasses

List of classes defined by PHP

protected static mixed $builtinClasses = []

$builtinInterfaces

List of interfaces defined by PHP

protected static mixed $builtinInterfaces = []

$fileskiplength

protected static mixed $fileskiplength = 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

$log_php

protected static mixed $log_php = 0

$logHash

protected static mixed $logHash = ''

$logPrefix

protected static mixed $logPrefix = ''

$logStreams

List of registered log streams

protected static array<string|int, mixed> $logStreams = []

$mode

protected static mixed $mode = 0

$startTime

Time in microseconds of first log event

protected static float $startTime = 0

Methods

__construct()

public __construct() : mixed

__internal__setup()

Set up debugging

public static __internal__setup() : void

Called by both activate() and deactivate()

activate()

Activates debugging according to the bits given in $mode

public static activate([int $mode = null ]) : void

See the constants defined early in this file. An empty $mode defaults to DBG_ALL & ~DBG_LOG_FILE

Parameters
$mode : int = null

The optional debugging mode bits

activateIf()

public static activateIf(mixed $condition[, mixed $mode = null ]) : void
Parameters
$condition : mixed
$mode : mixed = null

appendLogsToStreams()

Append logs to all registered log streams

public static appendLogsToStreams(array<string|int, mixed> $logs) : void
Parameters
$logs : array<string|int, mixed>

Logs to append to each registered stream. Each log must be an instance of DBG_Log.

calltrace()

Log the script file position along with the caller to the current method

public static calltrace([int $modeConstraint = DBG_LOG ]) : void
Parameters
$modeConstraint : int = DBG_LOG

Set to any of the available DBG basic flags to constrain the execution of the method to a specific DBG mode.

cleanfile()

public static cleanfile(mixed $f) : string
Parameters
$f : mixed
Return values
string

deactivate()

Deactivates debugging according to the bits given in $mode

public static deactivate([int $mode = null ]) : void

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) : void
Parameters
$message : mixed

deregisterLogStream()

Deregister a log stream

public static deregisterLogStream(string $name) : bool

After successful deregistration, no further logs are sent to the stream identified by $name.

Parameters
$name : string

Name of the stream to deregister.

Return values
bool

True if deregistering was successful. If $name is not in use,then false is returned.

dump()

Dump content of $val into the log.

public static dump(mixed $val[, int $modeConstraint = DBG_LOG ]) : void
Parameters
$val : mixed
$modeConstraint : int = DBG_LOG

Set to any of the available DBG basic flags to constrain the execution of the method to a specific DBG mode.

dumpExtendedLog()

Dump collected logs (by memory when using `DBG_LOG_MEMORY`) to extended log stream (`/tmp/log/extended_dbg.log`).

public static dumpExtendedLog([int $modeConstraint = DBG::FLAGS_LOG_VERBOSITY ]) : void
Parameters
$modeConstraint : int = DBG::FLAGS_LOG_VERBOSITY

Set to any of the available DBG basic flags to constrain the dumping to the specific log verbosity. Defaults to DBG::FLAGS_LOG_VERBOSITY. If set to DBG::FLAGS_LOG_VERBOSITY, but DBG_DB_DUMP_ON_ERROR is not set on DBG iteself, then DBG_DB won't be set.

getActivatedFlagsAsString()

Retrieve a string representation of activated flags

public static getActivatedFlagsAsString([int $mode = 0 ]) : string

Identify all set DBG flags in $mode and returned them as a string, joined by " | ". If $mode is not set (or set to 0) then the DBG flags are being identified as set by DBG::getMode().

Parameters
$mode : int = 0

Optional mode to evaluate. If not provided, the method uses the default mode returned by \DBG::getMode().

Return values
string

A string containing the activated flags joined by " | ".

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() : string
Return values
string

getLogPrefix()

Get currently set log prefix

public static getLogPrefix() : string
Tags
todo

The log prefix should be a property of a log stream.

Return values
string

The set log prefix.

getLogsFromStream()

public static getLogsFromStream(string $name) : array<string|int, mixed>
Parameters
$name : string

Name to refer to $stream.

Return values
array<string|int, mixed>

Logs from the stream identified by $name. Each log of the returned array is an instance of DBG_Log.

getMemoryLogs()

public static getMemoryLogs() : array<string|int, mixed>
Return values
array<string|int, mixed>

getMode()

Returns the current debugging mode bits

public static getMode() : int
Return values
int

The debugging mode bits

getUsableFlags()

Get a list of all available DBG flags that can be used on {@see static::activate()} and related methods during runtime.

public static getUsableFlags() : array<string|int, mixed>

This does include all DBG flags except the following

  • DBG_NONE
  • DBG_ALL
  • DBG_LOG_ (for changing the output device)
  • already enabled flags
Return values
array<string|int, mixed>

Array of all DBG flags having the form:

[
    '<flag>' -> <bit>,
    ...
]

hasCookie()

public static hasCookie(mixed $cookieName) : bool
Parameters
$cookieName : mixed
Return values
bool

hasCookieValue()

public static hasCookieValue(mixed $cookieName, mixed $cookieValue) : bool
Parameters
$cookieName : mixed
$cookieValue : mixed
Return values
bool

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) : bool
Parameters
$ip : mixed
Return values
bool

log()

public static log(mixed $text[, mixed $additional_args = null ]) : void
Parameters
$text : mixed
$additional_args : mixed = null

logSQL()

public static logSQL(mixed $sql, mixed $type) : void
Parameters
$sql : mixed
$type : mixed

msg()

public static msg(string $message[, int $modeConstraint = DBG_LOG ]) : void
Parameters
$message : string

The message to log.

$modeConstraint : int = DBG_LOG

Set to any of the available DBG basic flags to constrain the execution of the method to a specific DBG mode.

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) : void
Parameters
$errno : unknown_type
$errstr : unknown_type
$errfile : unknown_type
$errline : unknown_type

registerLogStream()

Register a stream to send logs to

public static registerLogStream(DBG_LogStream $stream, string $name) : bool
Parameters
$stream : DBG_LogStream

Instance to register as a log stream

$name : string

Name to refer to $stream.

Return values
bool

True if registering was successful. If $name is already in use, then false is returned.

resetLogPrefix()

Reset the text that is being put in front of log messags

public static resetLogPrefix() : void

setLogPrefix()

Set a text that will be put in front of all log messages

public static setLogPrefix([string $prefix = '' ]) : void
Parameters
$prefix : string = ''

The text that shall be put in front of log messages

Tags
todo

The log prefix should be a property of a log stream.

stack()

Dump a stack trace into the log.

public static stack([int $modeConstraint = DBG_LOG ]) : void
Parameters
$modeConstraint : int = DBG_LOG

Set to any of the available DBG basic flags to constrain the execution of the method to a specific DBG mode.

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()

Log the current script file position or a specific step from the stack- trace by setting `$level` to the desired level.

public static trace([int $level = 0 ][, int $modeConstraint = DBG_LOG ]) : void
Parameters
$level : int = 0

Set level of the stack-trace to log.

$modeConstraint : int = DBG_LOG

Set to any of the available DBG basic flags to constrain the execution of the method to a specific DBG mode.

writeFinishLine()

Writes the last line of a request to the log

public static writeFinishLine(Cx $cx, bool $cached[, string $outputModule = null ]) : void
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

_escapeDoctrineDump()

protected static _escapeDoctrineDump(mixed &$val) : void
Parameters
$val : mixed

_log()

protected static _log(mixed $text[, mixed $type = DBG_LOG ]) : void
Parameters
$text : mixed
$type : mixed = DBG_LOG

disable_error_reporting()

protected static disable_error_reporting() : void

disable_file()

Disables logging to a file

protected static disable_file() : void

disable_memory()

Disables logging to memory

protected static disable_memory() : void

enable_error_reporting()

protected static enable_error_reporting() : void

enable_file()

Enables logging to a file

protected static enable_file() : void

Disables logging to memory in turn.

enable_memory()

Enables logging to memory

protected static enable_memory() : void

enableCliOutput()

Register a log stream to output to stdout

protected static enableCliOutput() : void

enableExtendedLog()

Enable extended log stream (`/tmp/log/extended_dbg.log`)

protected static enableExtendedLog([int $modeConstraint = DBG::FLAGS_LOG_VERBOSITY ]) : bool
Parameters
$modeConstraint : int = DBG::FLAGS_LOG_VERBOSITY

Set to any of the available DBG basic flags to constrain the extended logging to the specific log verbosity. Defaults to DBG::FLAGS_LOG_VERBOSITY.

Return values
bool

getLogStoragePath()

protected static getLogStoragePath() : string
Return values
string

Path to storage location for log files


        
On this page

Search results