\RedBeanPHP\Logger\RDefaultDebug

Debug logger.

A special logger for debugging purposes. Provides debugging logging functions for RedBeanPHP.

Summary

Methods
Properties
Constants
log()
getLogs()
clear()
setMode()
grep()
setOverrideCLIOutput()
setParamStringLength()
setUseStringOnlyBinding()
No public properties found
C_LOGGER_ECHO
C_LOGGER_ARRAY
writeQuery()
fillInValue()
output()
normalizeSlots()
normalizeBindings()
$mode
$logs
$strLen
$noCLI
$flagUseStringOnlyBinding
N/A
No private methods found
No private properties found
N/A

Constants

C_LOGGER_ECHO

C_LOGGER_ECHO

Logger modes

C_LOGGER_ARRAY

C_LOGGER_ARRAY

Properties

$mode

$mode : integer

Type

integer

$logs

$logs : array

Type

array

$strLen

$strLen : integer

Type

integer

$noCLI

$noCLI : boolean

Type

boolean

$flagUseStringOnlyBinding

$flagUseStringOnlyBinding : boolean

Type

boolean

Methods

log()

log() : void

Logger method.

Takes a number of arguments tries to create a proper debug log based on the available data.

getLogs()

getLogs() : array

Returns the internal log array.

The internal log array is where all log messages are stored.

Returns

array

clear()

clear() : self

Clears the internal log array, removing all previously stored entries.

Returns

self

setMode()

setMode(integer  $mode) : self

Selects a logging mode.

There are several options available.

  • C_LOGGER_ARRAY - log silently, stores entries in internal log array only
  • C_LOGGER_ECHO - also forward log messages directly to STDOUT

Parameters

integer $mode

mode of operation for logging object

Returns

self

grep()

grep(string  $needle) : array

Searches for all log entries in internal log array for $needle and returns those entries.

This method will return an array containing all matches for your search query.

Parameters

string $needle

phrase to look for in internal log array

Returns

array

setOverrideCLIOutput()

setOverrideCLIOutput(boolean  $yesNo) : void

Toggles CLI override. By default debugging functions will output differently based on PHP_SAPI values. This function allows you to override the PHP_SAPI setting. If you set this to TRUE, CLI output will be suppressed in favour of HTML output. So, to get HTML on the command line use setOverrideCLIOutput( TRUE ).

Parameters

boolean $yesNo

CLI-override setting flag

setParamStringLength()

setParamStringLength(integer  $len = 20) : self

Sets the max string length for the parameter output in SQL queries. Set this value to a reasonable number to keep you SQL queries readable.

Parameters

integer $len

string length

Returns

self

setUseStringOnlyBinding()

setUseStringOnlyBinding(boolean  $yesNo = false) : self

Whether to bind all parameters as strings.

If set to TRUE this will cause all integers to be bound as STRINGS. This will NOT affect NULL values.

Parameters

boolean $yesNo

pass TRUE to bind all parameters as strings.

Returns

self

writeQuery()

writeQuery(string  $newSql, array  $newBindings) : string

Writes a query for logging with all bindings / params filled in.

Parameters

string $newSql

the query

array $newBindings

the bindings to process (key-value pairs)

Returns

string

fillInValue()

fillInValue(mixed  $value) : string

Fills in a value of a binding and truncates the resulting string if necessary.

Parameters

mixed $value

bound value

Returns

string

output()

output(string  $str) : void

Depending on the current mode of operation, this method will either log and output to STDIN or just log.

Depending on the value of constant PHP_SAPI this function will format output for console or HTML.

Parameters

string $str

string to log or output and log

normalizeSlots()

normalizeSlots(string  $sql) : string

Normalizes the slots in an SQL string.

Replaces question mark slots with :slot1 :slot2 etc.

Parameters

string $sql

sql to normalize

Returns

string

normalizeBindings()

normalizeBindings(array  $bindings) : array

Normalizes the bindings.

Replaces numeric binding keys with :slot1 :slot2 etc.

Parameters

array $bindings

bindings to normalize

Returns

array