Documentation

DBG_LogStream
in package

Tags
copyright

Cloudrexx AG

author

Thomas Wirz thomas.wirz@cloudrexx.com

subpackage

lib_dbg

Table of Contents

Constants

DATE_TIME_FORMAT  = 'Y-m-d H:i:s'
Date time format used for logs

Properties

$lastTime  : float
Delta in microseconds since last log event
$mode  : int
Debug mode of log stream
$stack  : array<string|int, mixed>
Container for logs
$startTime  : float
Time in microseconds of first log event

Methods

__construct()  : mixed
getStack()  : array<string|int, mixed>
Get all logs
push()  : void
Add new log `$log` to the stack (using {@see static::attachLog()}) and flush it to the stream (using {@see static::flush()}
setMode()  : mixed
attachLog()  : void
Add new log to the stack
flush()  : void
Flush the latest log (from {@see DBG_Log::$stack}) to the stream
flushLog()  : void
Flush log to the stream
getDate()  : string
Convert a given timestamp (with microseconds) to a formatted UTC date string
profileLog()  : void
This flushes a log entry (using {@see DBG_Log::flushLog()} that contains the time of the log entry, as well as the time that has been passed since: - the last log entry was generated - and request initialization Further, the generated log entry will contain the caller of this call.

Constants

DATE_TIME_FORMAT

Date time format used for logs

protected string DATE_TIME_FORMAT = 'Y-m-d H:i:s'

Properties

$lastTime

Delta in microseconds since last log event

protected float $lastTime = 0

$mode

Debug mode of log stream

protected int $mode = 0

Supports all DBG_* flags, except for DBG_LOG_FILE and DBG_LOG_MEMORY.

Tags
todo

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

$stack

Container for logs

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

Each log is an array having the keys log and type. log holds the actual log string. type is one of the DBG_ flags.

$startTime

Time in microseconds of first log event

protected float $startTime = 0

Methods

__construct()

public __construct(int $mode[, float $startTime = 0 ]) : mixed
Parameters
$mode : int

DBG_* flags

$startTime : float = 0

Time in microseconds of first log event of this request. If set to 0 (default), then the current time will be used.

getStack()

Get all logs

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

push()

Add new log `$log` to the stack (using {@see static::attachLog()}) and flush it to the stream (using {@see static::flush()}

public push(DBG_Log $log) : void

Depending on static::$mode and DBG_Log->getType() a profiling log will also be flushed to the stream by static::flush().

Parameters
$log : DBG_Log

Log instance to add to the stack

setMode()

public setMode(int $mode) : mixed
Parameters
$mode : int

DBG_* flags

attachLog()

Add new log to the stack

protected attachLog(DBG_Log $log) : void
Parameters
$log : DBG_Log

Log instance to add to the stack

flush()

Flush the latest log (from {@see DBG_Log::$stack}) to the stream

protected flush() : void

In case any of the following conditions are true, then this also generates a log entry that contains profiling information by using static::profileLog():

  • if $log->getProfiling() is set to DBG_PROFILE_FORCE
  • if static::$mode is set to DBG_PROFILE and $log->getType() is not set to DBG_PROFILE_OFF

flushLog()

Flush log to the stream

protected flushLog(DBG_Log $log) : void
Parameters
$log : DBG_Log

Log instance to flush

getDate()

Convert a given timestamp (with microseconds) to a formatted UTC date string

protected getDate(float $time, string $format) : string

This method takes a floating-point timestamp, generated using microtime(true) and returns the corresponding date-time string in UTC timezone formatted according to $format.

Parameters
$time : float

The timestamp to convert, as generated by microtime(true)

$format : string

The date-time format to use

Return values
string

The formatted date-time string in UTC timezone

profileLog()

This flushes a log entry (using {@see DBG_Log::flushLog()} that contains the time of the log entry, as well as the time that has been passed since: - the last log entry was generated - and request initialization Further, the generated log entry will contain the caller of this call.

protected profileLog(DBG_Log $log[, bool $logIsAfterCall = true ]) : 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 DBG::DBG_PROFILE_LOG_DELTA_THRESHOLD and mode DBG_DEBUG is enabled, then a stacktrace DBG::stack() is dumped.

Parameters
$log : DBG_Log

Log instance to profile.

$logIsAfterCall : bool = true

Set to true if this call is called after a reference call. If set, then this will generate a log entry stating TIME: ... AFTER. If set to false, the log entry will state TIME: ... AT.


        
On this page

Search results