Class: DebugProfiler

Class for debugging, tracing and profiling.

Implements

Authors

Oleg Schildt

Package

Source code

 

Properties
protected

Internal variable for storing the log path.

static private

Internal variable for storing the time by profiling.

protected

Internal variable for storing the flag that defines whether for each debug output the source file and line number are written from where it is called.

Methods
public

Clears the specified log file.

public

Clears all log files.

public

Logs a message to a standard debug output (logs/debug.log).

public

Sets the flag that defines whether the file name and the line number should be written along with the message.

protected

Extracts the call stack from the standard PHP backtrace (debug_backtrace).

public

Logs a message to a standard profiling output (logs/profile.log) and shows the time elapsed since the last call startProfilePoint or fixProfilePoint.

public

Initializes the debug profiler with parameters.

public

Logs a message to a standard profiling output (logs/profile.log) and stores the current time.

protected

This is an auxiliary function that cuts off the common part of the path.


Property: DebugProfiler::$log_path

protected ?string $log_path = null;

Internal variable for storing the log path.

Type

?string

Authors

Oleg Schildt

Source code


Property: DebugProfiler::$profile_time

private static int $profile_time;

Internal variable for storing the time by profiling.

Type

int

Authors

Oleg Schildt

Source code

See also


Property: DebugProfiler::$write_source_file_and_line_by_debug

protected bool $write_source_file_and_line_by_debug = false;

Internal variable for storing the flag that defines whether for each debug output the source file and line number are written from where it is called.

Type

bool

Authors

Oleg Schildt

Source code


Method: DebugProfiler::clearLogFile()

public function clearLogFile(string $file_name): void;

Clears the specified log file.

Parameters

Name Pass type Value type Default value Description
$file_name by value string

The target file name.

Returns

void

Overrides

Authors

Oleg Schildt

Source code

See also


Method: DebugProfiler::clearLogFiles()

public function clearLogFiles(): void;

Clears all log files.

Returns

void

Overrides

Authors

Oleg Schildt

Source code

See also


Method: DebugProfiler::debugMessage()

public function debugMessage(string $message, bool $write_call_stack = false, string $file_name = "debug.log"): void;

Logs a message to a standard debug output (logs/debug.log).

Parameters

Name Pass type Value type Default value Description
$message by value string

Message to be logged.

$write_call_stack by value bool false

Flag that defines where the call stack should be written.

$file_name by value string "debug.log"

The target file name.

Returns

void

Throws

\Exception

It might throw an exception in the case of any errors:

  • if the debug file is not writable.

Overrides

Authors

Oleg Schildt

Source code


Method: DebugProfiler::enableFileAndLineDetails()

public function enableFileAndLineDetails(bool $state): void;

Sets the flag that defines whether the file name and the line number should be written along with the message.

Parameters

Name Pass type Value type Default value Description
$state by value bool

the flag that defines whether the file name and the line number should be written along with the message.

Returns

void

Authors

Oleg Schildt

Source code


Method: DebugProfiler::extract_call_stack()

protected function extract_call_stack(array $btrace): string;

Extracts the call stack from the standard PHP backtrace (debug_backtrace).

Parameters

Name Pass type Value type Default value Description
$btrace by value array

The backtrace.

Returns

string

Returns the extracted call stack.

Authors

Oleg Schildt

Source code


Method: DebugProfiler::fixProfilePoint()

public function fixProfilePoint(string $message): void;

Logs a message to a standard profiling output (logs/profile.log) and shows the time elapsed since the last call startProfilePoint or fixProfilePoint.

Parameters

Name Pass type Value type Default value Description
$message by value string

Message to be logged.

Returns

void

Throws

\Exception

It might throw an exception in the case of any errors:

  • if the profile file is not writable.

Overrides

Authors

Oleg Schildt

Source code

See also


Method: DebugProfiler::init()

public function init(array $parameters): void;

Initializes the debug profiler with parameters.

Parameters

Name Pass type Value type Default value Description
$parameters by value array

Settings for logging as an associative array in the form key => value:

  • $parameters["log_path"] - the target file path where the logs should be stored.

  • $parameters["write_source_file_and_line_by_debug"] - the flag that defines whether for each debug output the source file and line number are written from where it is called.

Returns

void

Throws

\Exception

It might throw an exception in the case of any system errors:

  • if the log path is not specified.
  • if the trace file is not writable.

Overrides

Authors

Oleg Schildt

Source code


Method: DebugProfiler::startProfilePoint()

public function startProfilePoint(string $message): void;

Logs a message to a standard profiling output (logs/profile.log) and stores the current time.

Parameters

Name Pass type Value type Default value Description
$message by value string

Message to be logged.

Returns

void

Throws

\Exception

It might throw an exception in the case of any errors:

  • if the profile file is not writable.

Overrides

Authors

Oleg Schildt

Source code

See also


Method: DebugProfiler::trim_path()

protected function trim_path(string $path): string;

This is an auxiliary function that cuts off the common part of the path.

Parameters

Name Pass type Value type Default value Description
$path by value string

The path.

Returns

string

Returns the cut path.

Authors

Oleg Schildt

Source code