Logger
extends AbstractLogger
in package
Minimalist PSR-3 logger designed to write in stderr or any other stream.
Tags
Table of Contents
Constants
- LEVELS = [\Psr\Log\LogLevel::DEBUG => 0, \Psr\Log\LogLevel::INFO => 1, \Psr\Log\LogLevel::NOTICE => 2, \Psr\Log\LogLevel::WARNING => 3, \Psr\Log\LogLevel::ERROR => 4, \Psr\Log\LogLevel::CRITICAL => 5, \Psr\Log\LogLevel::ALERT => 6, \Psr\Log\LogLevel::EMERGENCY => 7]
Properties
- $formatter : Closure
- $handle : resource|null
- $minLevelIndex : int
Methods
- __construct() : mixed
- alert() : void
- Action must be taken immediately.
- critical() : void
- Critical conditions.
- debug() : void
- Detailed debug information.
- emergency() : void
- System is unusable.
- error() : void
- Runtime errors that do not require immediate action but should typically be logged and monitored.
- info() : void
- Interesting events.
- log() : void
- {@inheritdoc}
- notice() : void
- Normal but significant events.
- warning() : void
- Exceptional occurrences that are not errors.
- format() : string
Constants
LEVELS
private
mixed
LEVELS
= [\Psr\Log\LogLevel::DEBUG => 0, \Psr\Log\LogLevel::INFO => 1, \Psr\Log\LogLevel::NOTICE => 2, \Psr\Log\LogLevel::WARNING => 3, \Psr\Log\LogLevel::ERROR => 4, \Psr\Log\LogLevel::CRITICAL => 5, \Psr\Log\LogLevel::ALERT => 6, \Psr\Log\LogLevel::EMERGENCY => 7]
Properties
$formatter
private
Closure
$formatter
$handle
private
resource|null
$handle
$minLevelIndex
private
int
$minLevelIndex
Methods
__construct()
public
__construct([string $minLevel = null ][, string|resource|null $output = null ][, callable $formatter = null ]) : mixed
Parameters
- $minLevel : string = null
- $output : string|resource|null = null
- $formatter : callable = null
alert()
Action must be taken immediately.
public
alert(string|Stringable $message[, array<string|int, mixed> $context = [] ]) : void
Example: Entire website down, database unavailable, etc. This should trigger the SMS alerts and wake you up.
Parameters
- $message : string|Stringable
- $context : array<string|int, mixed> = []
critical()
Critical conditions.
public
critical(string|Stringable $message[, array<string|int, mixed> $context = [] ]) : void
Example: Application component unavailable, unexpected exception.
Parameters
- $message : string|Stringable
- $context : array<string|int, mixed> = []
debug()
Detailed debug information.
public
debug(string|Stringable $message[, array<string|int, mixed> $context = [] ]) : void
Parameters
- $message : string|Stringable
- $context : array<string|int, mixed> = []
emergency()
System is unusable.
public
emergency(string|Stringable $message[, array<string|int, mixed> $context = [] ]) : void
Parameters
- $message : string|Stringable
- $context : array<string|int, mixed> = []
error()
Runtime errors that do not require immediate action but should typically be logged and monitored.
public
error(string|Stringable $message[, array<string|int, mixed> $context = [] ]) : void
Parameters
- $message : string|Stringable
- $context : array<string|int, mixed> = []
info()
Interesting events.
public
info(string|Stringable $message[, array<string|int, mixed> $context = [] ]) : void
Example: User logs in, SQL logs.
Parameters
- $message : string|Stringable
- $context : array<string|int, mixed> = []
log()
{@inheritdoc}
public
log(mixed $level, mixed $message[, array<string|int, mixed> $context = [] ]) : void
Parameters
- $level : mixed
- $message : mixed
- $context : array<string|int, mixed> = []
notice()
Normal but significant events.
public
notice(string|Stringable $message[, array<string|int, mixed> $context = [] ]) : void
Parameters
- $message : string|Stringable
- $context : array<string|int, mixed> = []
warning()
Exceptional occurrences that are not errors.
public
warning(string|Stringable $message[, array<string|int, mixed> $context = [] ]) : void
Example: Use of deprecated APIs, poor use of an API, undesirable things that are not necessarily wrong.
Parameters
- $message : string|Stringable
- $context : array<string|int, mixed> = []
format()
private
format(string $level, string $message, array<string|int, mixed> $context[, bool $prefixDate = true ]) : string
Parameters
- $level : string
- $message : string
- $context : array<string|int, mixed>
- $prefixDate : bool = true