Logger implements LoggerInterface
Interfaces, Classes and Traits
- LoggerInterface
Table of Contents
- LEVEL_MAP = [PsrLogLogLevel::EMERGENCY => 800, PsrLogLogLevel::ALERT => 700, PsrLogLogLevel::CRITICAL => 600, PsrLogLogLevel::ERROR => 500, PsrLogLogLevel::WARNING => 400, PsrLogLogLevel::NOTICE => 300, PsrLogLogLevel::INFO => 200, PsrLogLogLevel::DEBUG => 100]
- $_default_log_level : mixed
- $_name : mixed
- __construct() : mixed
- Constructor
- 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
- Logs with an arbitrary level.
- notice() : void
- Normal but significant events.
- warning() : void
- Exceptional occurrences that are not errors.
- _print_log() : void
- Internal function that prints log messages to STDOUT Data passed into $context will be converted to JSON
Constants
LEVEL_MAP
private
mixed
LEVEL_MAP
= [PsrLogLogLevel::EMERGENCY => 800, PsrLogLogLevel::ALERT => 700, PsrLogLogLevel::CRITICAL => 600, PsrLogLogLevel::ERROR => 500, PsrLogLogLevel::WARNING => 400, PsrLogLogLevel::NOTICE => 300, PsrLogLogLevel::INFO => 200, PsrLogLogLevel::DEBUG => 100]
Properties
$_default_log_level
private
mixed
$_default_log_level
$_name
private
mixed
$_name
Methods
__construct()
Constructor
public
__construct(string $name[, string $default_log_level = LogLevel::INFO ]) : mixed
Parameters
- $name : string
-
The name of the application
- $default_log_level : string = LogLevel::INFO
-
The minumum LogLevel to print messages for
Return values
mixed —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()
Return values
void —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()
Return values
void —debug()
Detailed debug information.
public
debug(string $message[, array<string|int, mixed> $context = array() ]) : void
Parameters
- $message : string
- $context : array<string|int, mixed> = array()
Return values
void —emergency()
System is unusable.
public
emergency(string $message[, array<string|int, mixed> $context = array() ]) : void
Parameters
- $message : string
- $context : array<string|int, mixed> = array()
Return values
void —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()
Return values
void —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()
Return values
void —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()
Tags
Return values
void —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()
Return values
void —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()
Return values
void —_print_log()
Internal function that prints log messages to STDOUT Data passed into $context will be converted to JSON
private
_print_log(string $level, string $message, array<string|int, mixed> $context) : void
Parameters
- $level : string
-
The LogLevel of the message
- $message : string
-
The message to print
- $context : array<string|int, mixed>
-
Additional data to include in the output