Logger
extends Base
in package
Uses
Singleton
Logging and reporting.
Features:
- Automaticly adds a statusbar entry.
- Automatic truncating of very large messages.
- Limits for the detailed log
- Customizable columns and renderer.
- Ability to add a backtrace per log message.
Table of Contents
- $backtrace : int
- Add N filename and linenumber traces to the log.
- $characterLimit : int
- Only log the first 50KiB of a long log entry.
- $columns : array<string|int, mixed>
- Columnnames for the popup log table.
- $count : int
- Total number of "actions" (may exceed the $limit).
- $entries : array<string|int, mixed>
- $instances : array<string|int, static>
- The instances that are accessible by class::instance() [ 'id' => instance, // direct mapping to an instance 'id2' => 'id' // indirect mapping to an instance 'id3' => function () { return new Sington() } // lazy creation of an instance.
- $limit : int
- Maximum number of "actions" that will be logged. (-1: Unlimited).
- $plural : string
- Plural description of the entry type. Example: "requests", "queries", etc.
- $renderer : Closure|array<string|int, mixed>|string
- Callback for rendering the log entry <td>'s.
- $singular : string
- Singular description of the entry type: Example: "request", "query", etc.
- $start : int
- Start the numbering at .. (is 0 for databases to compensate for the connect "query").
- $totalDuration : float
- Total elapsed time it took to execute all "actions" (in seconds) Collects all 'duration' values in the $meta array.
- __call() : mixed
- Report that the $method doesn't exist.
- __callStatic() : mixed
- Report that the $method doesn't exist.
- __construct() : mixed
- Constructor.
- __get() : mixed
- Report that $property doesn't exist.
- __set() : mixed
- Report that $property doesn't exist and set the property to the given $value.
- __toString() : string
- The object is used as an string.
- __wakeup() : mixed
- append() : mixed
- Add an entry to the log.
- instance() : static
- Get the singleton instance.
- render() : mixed
- Renders all logged entries in a <table>.
- renderEntry() : mixed
- Default renderer for a log entry (override with the $logger->renderer property).
- statusbar() : mixed
- Render the log in a 1 line summary and the table in a popup.
- defaultInstance() : static
- Create a default instance.
- collectBacktrace() : null|array<string|int, mixed>
- Trace the location where the log was called from.
Properties
$backtrace
Add N filename and linenumber traces to the log.
public
int
$backtrace
= 0
$characterLimit
Only log the first 50KiB of a long log entry.
public
int
$characterLimit
= 51200
$columns
Columnnames for the popup log table.
public
array<string|int, mixed>
$columns
$count
Total number of "actions" (may exceed the $limit).
public
int
$count
= 0
$entries
public
array<string|int, mixed>
$entries
= []
$instances
The instances that are accessible by class::instance() [ 'id' => instance, // direct mapping to an instance 'id2' => 'id' // indirect mapping to an instance 'id3' => function () { return new Sington() } // lazy creation of an instance.
public
static array<string|int, static>
$instances
= []
].
$limit
Maximum number of "actions" that will be logged. (-1: Unlimited).
public
int
$limit
= -1
$plural
Plural description of the entry type. Example: "requests", "queries", etc.
public
string
$plural
= 'entries'
$renderer
Callback for rendering the log entry <td>'s.
public
Closure|array<string|int, mixed>|string
$renderer
$singular
Singular description of the entry type: Example: "request", "query", etc.
public
string
$singular
= 'entry'
$start
Start the numbering at .. (is 0 for databases to compensate for the connect "query").
public
int
$start
= 1
$totalDuration
Total elapsed time it took to execute all "actions" (in seconds) Collects all 'duration' values in the $meta array.
public
float
$totalDuration
= 0.0
Methods
__call()
Report that the $method doesn't exist.
public
__call(string $method, array<string|int, mixed> $arguments) : mixed
Parameters
- $method : string
- $arguments : array<string|int, mixed>
Return values
mixed —__callStatic()
Report that the $method doesn't exist.
public
static __callStatic(string $method, array<string|int, mixed> $arguments) : mixed
Parameters
- $method : string
- $arguments : array<string|int, mixed>
Return values
mixed —__construct()
Constructor.
public
__construct([array<string|int, mixed> $options = [] ]) : mixed
Parameters
- $options : array<string|int, mixed> = []
Return values
mixed —__get()
Report that $property doesn't exist.
public
__get(string $property) : mixed
Parameters
- $property : string
Return values
mixed —__set()
Report that $property doesn't exist and set the property to the given $value.
public
__set(string $property, mixed $value) : mixed
Parameters
- $property : string
- $value : mixed
Return values
mixed —__toString()
The object is used as an string.
public
__toString() : string
Return values
string —__wakeup()
public
__wakeup() : mixed
Return values
mixed —append()
Add an entry to the log.
public
append(string $entry[, array<string|int, mixed> $meta = [] ]) : mixed
Parameters
- $entry : string
- $meta : array<string|int, mixed> = []
-
array( 'duration' => (optional) the elapsed time for this "action" )
Return values
mixed —instance()
Get the singleton instance.
public
static instance([string $identifier = 'default' ]) : static
Parameters
- $identifier : string = 'default'
-
The identifier (string),
Return values
static —render()
Renders all logged entries in a <table>.
public
render() : mixed
Return values
mixed —renderEntry()
Default renderer for a log entry (override with the $logger->renderer property).
public
static renderEntry(string $entry, mixed $meta) : mixed
Parameters
- $entry : string
- $meta : mixed
Return values
mixed —statusbar()
Render the log in a 1 line summary and the table in a popup.
public
statusbar(string $name) : mixed
Parameters
- $name : string
Return values
mixed —defaultInstance()
Create a default instance.
protected
static defaultInstance() : static
Override in the (sub)class to create an instance with default parameters.
Return values
static —collectBacktrace()
Trace the location where the log was called from.
private
collectBacktrace() : null|array<string|int, mixed>