\digger\firetoolsDebug

A most simple but powerful debug utility.

Static library.

PHP Version 7.1

Summary

Methods
Properties
Constants
log()
catchErrors()
$enableTime
$defaultLogFilePath
$constantNameForLogFilePath
$logFileName
No constants found
exceptionHandler()
errorHandler()
shutdownHandler()
createLogFileName()
getLogFileName()
getTime()
createLogMessage()
save()
$createdLogFileName
N/A
No private methods found
No private properties found
N/A

Properties

$enableTime

$enableTime : boolean

Enables or disables date time stamp in the log messages

Type

boolean

$defaultLogFilePath

$defaultLogFilePath : string

Defines the default path for log file

Type

string

$constantNameForLogFilePath

$constantNameForLogFilePath : string

Defines the name of the constant that store a path for log files

Type

string

$logFileName

$logFileName : string

Defines the log file name

Possible options:

  • The log file full name.
  • Or just a name of the file. In this case full name will be created by using the path is defined by constant with name stored in $constantNameForLogFilePath. If no constant is defined the default path ($defaultLogFilePath) will be used.

Type

string

$createdLogFileName

$createdLogFileName : string

Cached log file name

Type

string

Methods

log()

log(mixed  $args) 

Saves a log data of any type.

Example of using:

     Debug::log();                                 //<--- The arguments of calling function will be added to the log
     Debug::log('Hello');                          //<--- 'Hello' will be added to the log
     Debug::log('My data', 123, 'test', [1,2,3]);  //<--- All this data will be added to the log
     Debug::log(['My' => 'Hash']);                 //<--- The array will be added to the log

Parameters

mixed $args

catchErrors()

catchErrors() 

Sets handlers to catch program errors and exceptions and save it to the log.

Example of using:

     Debug::catchErrors(); // <--- At any place of code before a potential error

exceptionHandler()

exceptionHandler(\Error  $e) 

Registers an exception handler

Parameters

\Error $e

The error object

errorHandler()

errorHandler(integer  $errno, string  $errstr, string  $errfile, integer  $errline) 

Registers an error handler

Parameters

integer $errno
string $errstr
string $errfile
integer $errline

shutdownHandler()

shutdownHandler() 

Registers a shutdown handler

createLogFileName()

createLogFileName() : string

Creates the full name for log file

Returns

string —

The log file full name

getLogFileName()

getLogFileName() : string

Returns the full name of the log file

Returns

string —

The log file full name

getTime()

getTime() : string

Returns the current time stamp

Returns

string —

Current time stamp

createLogMessage()

createLogMessage(string  $text) : string

Creates the formatted log string

Parameters

string $text

String with some log data

Returns

string —

Final formatted log string

save()

save(string  $content) : boolean|integer

Saves the log content

Parameters

string $content

Returns

boolean|integer