Aplus Framework Docs

FileLogger extends Logger
in package

Class FileLogger.

Table of Contents

$config  : array<string|int, mixed>
$debugCollector  : LogCollector
$destination  : string
Logs destination.
$lastLog  : Log|null
$level  : LogLevel
Active log level.
__construct()  : mixed
Logger constructor.
getDestination()  : string
getLastLog()  : Log|null
Get the last accepted log in the current instance.
getLevel()  : LogLevel
log()  : bool
Logs with an arbitrary level.
logAlert()  : bool
Level 6: Action must be taken immediately.
logCritical()  : bool
Level 5: Critical conditions.
logDebug()  : bool
Level 0: Detailed debug information.
logEmergency()  : bool
Level 7: System is unusable.
logError()  : bool
Level 4: Runtime errors that do not require immediate action but should typically be logged and monitored.
logInfo()  : bool
Level 1: Interesting events.
logNotice()  : bool
Level 2: Normal but significant events.
logWarning()  : bool
Level 3: Exceptional occurrences that are not errors.
setDebugCollector()  : static
setLevel()  : static
getConfig()  : array<string|int, mixed>
makeId()  : string
replaceContext()  : string
setConfig()  : static
setDestination()  : static
write()  : bool

Properties

$config

protected array<string|int, mixed> $config

$destination

Logs destination.

protected string $destination

$level

Active log level.

protected LogLevel $level = \Framework\Log\LogLevel::DEBUG

Methods

__construct()

Logger constructor.

public __construct(string $destination[, LogLevel|int $level = LogLevel::DEBUG ][, array<string|int, mixed> $config = [] ]) : mixed
Parameters
$destination : string
$level : LogLevel|int = LogLevel::DEBUG
$config : array<string|int, mixed> = []
Return values
mixed

getDestination()

public getDestination() : string
Return values
string

getLastLog()

Get the last accepted log in the current instance.

public getLastLog() : Log|null
Return values
Log|null

The last Log or null if the last was not accepted

log()

Logs with an arbitrary level.

public log(LogLevel|int $level, string $message[, array<string|int, string> $context = [] ]) : bool
Parameters
$level : LogLevel|int
$message : string
$context : array<string|int, string> = []
Return values
bool

logAlert()

Level 6: Action must be taken immediately.

public logAlert(string $message[, array<string|int, string> $context = [] ]) : bool

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

Parameters
$message : string
$context : array<string|int, string> = []
Return values
bool

logCritical()

Level 5: Critical conditions.

public logCritical(string $message[, array<string|int, string> $context = [] ]) : bool

Example: Application component unavailable, unexpected exception.

Parameters
$message : string
$context : array<string|int, string> = []
Return values
bool

logDebug()

Level 0: Detailed debug information.

public logDebug(string $message[, array<string|int, string> $context = [] ]) : bool
Parameters
$message : string
$context : array<string|int, string> = []
Return values
bool

logEmergency()

Level 7: System is unusable.

public logEmergency(string $message[, array<string|int, string> $context = [] ]) : bool
Parameters
$message : string
$context : array<string|int, string> = []
Return values
bool

logError()

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

public logError(string $message[, array<string|int, string> $context = [] ]) : bool
Parameters
$message : string
$context : array<string|int, string> = []
Return values
bool

logInfo()

Level 1: Interesting events.

public logInfo(string $message[, array<string|int, string> $context = [] ]) : bool

Example: User logs in, SQL logs.

Parameters
$message : string
$context : array<string|int, string> = []
Return values
bool

logNotice()

Level 2: Normal but significant events.

public logNotice(string $message[, array<string|int, string> $context = [] ]) : bool
Parameters
$message : string
$context : array<string|int, string> = []
Return values
bool

logWarning()

Level 3: Exceptional occurrences that are not errors.

public logWarning(string $message[, array<string|int, string> $context = [] ]) : bool

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

Parameters
$message : string
$context : array<string|int, string> = []
Return values
bool

setDebugCollector()

public setDebugCollector(LogCollector $debugCollector) : static
Parameters
$debugCollector : LogCollector
Return values
static

setLevel()

public setLevel(LogLevel|int $level) : static
Parameters
$level : LogLevel|int
Return values
static

getConfig()

protected getConfig() : array<string|int, mixed>
Return values
array<string|int, mixed>

makeId()

protected makeId() : string
Return values
string

replaceContext()

protected replaceContext(string $message, array<string|int, string> $context) : string
Parameters
$message : string
$context : array<string|int, string>
Return values
string

setConfig()

protected setConfig(array<string|int, mixed> $config) : static
Parameters
$config : array<string|int, mixed>
Return values
static

setDestination()

protected setDestination(string $destination) : static
Parameters
$destination : string
Return values
static

write()

protected write(Log $log) : bool
Parameters
$log : Log
Return values
bool

Search results