ConsoleLogger
extends AbstractLogger
in package
implements
LoggerInterface
This is a simple Logger implementation that other Loggers can inherit from.
It simply delegates all log-level-specific methods to the log
method to
reduce boilerplate code that a simple Logger that does the same thing with
messages regardless of the error level has to implement.
Interfaces, Classes, Traits and Enums
- LoggerInterface
- Describes a logger instance.
Table of Contents
- COLOR_ERROR = "\x1b[31m"
- COLOR_STOP = "\x1b[0m"
- COLOR_WARNING = "\x1b[33m"
- $called : bool
- $debug : bool
- __construct() : mixed
- alert() : void
- Action must be taken immediately.
- called() : mixed
- 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
- Logs with an arbitrary level.
- notice() : void
- Normal but significant events.
- warning() : void
- Exceptional occurrences that are not errors.
Constants
COLOR_ERROR
public
mixed
COLOR_ERROR
= "\x1b[31m"
COLOR_STOP
public
mixed
COLOR_STOP
= "\x1b[0m"
COLOR_WARNING
public
mixed
COLOR_WARNING
= "\x1b[33m"
Properties
$called
protected
bool
$called
= false
$debug
protected
bool
$debug
Methods
__construct()
public
__construct([bool $debug = false ]) : mixed
Parameters
- $debug : bool = false
Return values
mixed —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> = []
Return values
void —called()
public
called() : mixed
Return values
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> = []
Return values
void —debug()
Detailed debug information.
public
debug(string|Stringable $message[, array<string|int, mixed> $context = [] ]) : void
Parameters
- $message : string|Stringable
- $context : array<string|int, mixed> = []
Return values
void —emergency()
System is unusable.
public
emergency(string|Stringable $message[, array<string|int, mixed> $context = [] ]) : void
Parameters
- $message : string|Stringable
- $context : array<string|int, mixed> = []
Return values
void —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> = []
Return values
void —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> = []
Return values
void —log()
Logs with an arbitrary level.
public
log(mixed $level, mixed $message[, array<string|int, mixed> $context = [] ]) : void
Parameters
- $level : mixed
- $message : mixed
- $context : array<string|int, mixed> = []
-
additional details; supports custom
prefix
andexception
Return values
void —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> = []
Return values
void —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> = []