Documentation

Logger
in package
implements LoggerInterface Uses TEventDispatcher

AbstractYes

Represents a logger for logging messages.

This abstract class provides a structure for logging messages. It implements the PSR-3 LoggerInterface and uses an event dispatcher to handle logging events.

Table of Contents

Interfaces

LoggerInterface

Constants

Alert  = 1
Critical  = 2
Debug  = 7
Emergency  = 0
Error  = 3
Informational  = 6
Notice  = 5
Warning  = 4

Properties

$_device  : mixed
The name of the log file.
$_maxLogLevel  : int
The maximum log level.

Methods

alert()  : void
Action must be taken immediately.
Content()  : mixed
Retrieves the content of the log file.
Create()  : Logger
Creates a logger instance based on the provided configuration.
critical()  : void
Critical conditions.
debug()  : void
Detailed debug information.
DispatchEvent()  : object|null
Dispatches an event.
emergency()  : void
System is unusable.
error()  : void
Runtime errors that do not require immediate action but should typically be logged and monitored.
HandleEvent()  : self
Adds an event handler.
info()  : void
Interesting events.
log()  : void
Logs with an arbitrary level.
notice()  : void
Normal but significant events.
RemoveHandler()  : self
Removes an event handler.
warning()  : void
Exceptional occurrences that are not errors.
WriteLine()  : void
Writes a log line.

Constants

Alert

public int Alert = 1

Alert level constant.

Critical

public int Critical = 2

Critical level constant.

Debug

public int Debug = 7

Debug level constant.

Emergency

public int Emergency = 0

Emergency level constant.

Error

public int Error = 3

Error level constant.

Informational

public int Informational = 6

Informational level constant.

Notice

public int Notice = 5

Notice level constant.

Warning

public int Warning = 4

Warning level constant.

Properties

$_device

The name of the log file.

protected mixed $_device

$_maxLogLevel

The maximum log level.

protected int $_maxLogLevel = 7

Methods

alert()

Action must be taken immediately.

public alert(string $message[, array<string|int, mixed> $context = array() ]) : void

Example: Entire website down, database unavailable, etc. This should trigger the SMS alerts and wake you up.

Parameters
$message : string
$context : array<string|int, mixed> = array()

Content()

Retrieves the content of the log file.

public abstract Content() : mixed
Tags
abstract
Return values
mixed

The content of the log file.

Create()

Creates a logger instance based on the provided configuration.

public static Create(Config|array<string|int, mixed> $loggerConfig) : Logger
Parameters
$loggerConfig : Config|array<string|int, mixed>

The logger configuration.

Tags
throws
LoggerException

When an invalid logger type is provided.

Return values
Logger

The logger instance.

critical()

Critical conditions.

public critical(string $message[, array<string|int, mixed> $context = array() ]) : void

Example: Application component unavailable, unexpected exception.

Parameters
$message : string
$context : array<string|int, mixed> = array()

debug()

Detailed debug information.

public debug(string $message[, array<string|int, mixed> $context = array() ]) : void
Parameters
$message : string
$context : array<string|int, mixed> = array()

DispatchEvent()

Dispatches an event.

public DispatchEvent(string|Event $event[, mixed $args = null ][, bool $async = false ]) : object|null
Parameters
$event : string|Event

The event object or its name.

$args : mixed = null

Additional arguments to pass to the event handlers.

$async : bool = false

Whether to dispatch the event asynchronously.

Return values
object|null

The event object with updated arguments, or null if the event does not exist.

emergency()

System is unusable.

public emergency(string $message[, array<string|int, mixed> $context = array() ]) : void
Parameters
$message : string
$context : array<string|int, mixed> = array()
Tags
testFunction

testLoggerEmergency

error()

Runtime errors that do not require immediate action but should typically be logged and monitored.

public error(string $message[, array<string|int, mixed> $context = array() ]) : void
Parameters
$message : string
$context : array<string|int, mixed> = array()

HandleEvent()

Adds an event handler.

public HandleEvent(array<string|int, mixed>|string $ename, mixed $listener) : self
Parameters
$ename : array<string|int, mixed>|string

The event name or an array of event names.

$listener : mixed

The event handler.

Return values
self

info()

Interesting events.

public info(string $message[, array<string|int, mixed> $context = array() ]) : void

Example: User logs in, SQL logs.

Parameters
$message : string
$context : array<string|int, mixed> = array()

log()

Logs with an arbitrary level.

public log(mixed $level, string $message[, array<string|int, mixed> $context = array() ]) : void
Parameters
$level : mixed
$message : string
$context : array<string|int, mixed> = array()

notice()

Normal but significant events.

public notice(string $message[, array<string|int, mixed> $context = array() ]) : void
Parameters
$message : string
$context : array<string|int, mixed> = array()

RemoveHandler()

Removes an event handler.

public RemoveHandler(string $ename, mixed $listener) : self
Parameters
$ename : string

The event name.

$listener : mixed

The event handler to remove.

Return values
self

warning()

Exceptional occurrences that are not errors.

public warning(string $message[, array<string|int, mixed> $context = array() ]) : void

Example: Use of deprecated APIs, poor use of an API, undesirable things that are not necessarily wrong.

Parameters
$message : string
$context : array<string|int, mixed> = array()

WriteLine()

Writes a log line.

public abstract WriteLine(int $level, mixed $data) : void
Parameters
$level : int

The log level.

$data : mixed

The log data.

Tags
abstract

        
On this page

Search results