Logger
in package
Logger class
Tags
Table of Contents
Constants
- ALERT = 1
- CRITICAL = 2
- DEBUG = 7
- EMERGENCY = 0
- Constants for log levels
- ERROR = 3
- INFO = 6
- NOTICE = 5
- WARNING = 4
Properties
- $levels : array<string|int, mixed>
- Message level short codes
- $timestampFormat : string
- Log timestamp format
- $writers : array<string|int, mixed>
- Log writers
Methods
- __construct() : mixed
- Constructor
- addWriter() : Logger
- Add a log writer
- addWriters() : Logger
- Add log writers
- alert() : Logger
- Add an ALERT log entry
- critical() : Logger
- Add a CRITICAL log entry
- debug() : Logger
- Add a DEBUG log entry
- emergency() : Logger
- Add an EMERGENCY log entry
- error() : Logger
- Add an ERROR log entry
- getLevel() : string
- Get level
- getLogLevel() : string
- Static method to get log level
- getTimestampFormat() : string
- Get timestamp format
- getWriters() : array<string|int, mixed>
- Get all log writers
- info() : Logger
- Add an INFO log entry
- log() : Logger
- Add a log entry
- notice() : Logger
- Add a NOTICE log entry
- setLogLimit() : Logger
- Set log level limit for all log writers
- setTimestampFormat() : Logger
- Set timestamp format
- warning() : Logger
- Add a WARNING log entry
Constants
ALERT
public
mixed
ALERT
= 1
CRITICAL
public
mixed
CRITICAL
= 2
DEBUG
public
mixed
DEBUG
= 7
EMERGENCY
Constants for log levels
public
int
EMERGENCY
= 0
ERROR
public
mixed
ERROR
= 3
INFO
public
mixed
INFO
= 6
NOTICE
public
mixed
NOTICE
= 5
WARNING
public
mixed
WARNING
= 4
Properties
$levels
Message level short codes
protected
array<string|int, mixed>
$levels
= [0 => 'EMERGENCY', 1 => 'ALERT', 2 => 'CRITICAL', 3 => 'ERROR', 4 => 'WARNING', 5 => 'NOTICE', 6 => 'INFO', 7 => 'DEBUG']
$timestampFormat
Log timestamp format
protected
string
$timestampFormat
= 'Y-m-d H:i:s'
$writers
Log writers
protected
array<string|int, mixed>
$writers
= []
Methods
__construct()
Constructor
public
__construct([WriterInterface|array<string|int, mixed>|null $writer = [] ][, string $timestampFormat = 'Y-m-d H:i:s' ]) : mixed
Instantiate the logger object
Parameters
- $writer : WriterInterface|array<string|int, mixed>|null = []
- $timestampFormat : string = 'Y-m-d H:i:s'
addWriter()
Add a log writer
public
addWriter(WriterInterface $writer) : Logger
Parameters
- $writer : WriterInterface
Return values
LoggeraddWriters()
Add log writers
public
addWriters(array<string|int, mixed> $writers) : Logger
Parameters
- $writers : array<string|int, mixed>
Return values
Loggeralert()
Add an ALERT log entry
public
alert(mixed $message[, array<string|int, mixed> $context = [] ]) : Logger
Parameters
- $message : mixed
- $context : array<string|int, mixed> = []
Return values
Loggercritical()
Add a CRITICAL log entry
public
critical(mixed $message[, array<string|int, mixed> $context = [] ]) : Logger
Parameters
- $message : mixed
- $context : array<string|int, mixed> = []
Return values
Loggerdebug()
Add a DEBUG log entry
public
debug(mixed $message[, array<string|int, mixed> $context = [] ]) : Logger
Parameters
- $message : mixed
- $context : array<string|int, mixed> = []
Return values
Loggeremergency()
Add an EMERGENCY log entry
public
emergency(mixed $message[, array<string|int, mixed> $context = [] ]) : Logger
Parameters
- $message : mixed
- $context : array<string|int, mixed> = []
Return values
Loggererror()
Add an ERROR log entry
public
error(mixed $message[, array<string|int, mixed> $context = [] ]) : Logger
Parameters
- $message : mixed
- $context : array<string|int, mixed> = []
Return values
LoggergetLevel()
Get level
public
getLevel(int $level) : string
Parameters
- $level : int
Return values
stringgetLogLevel()
Static method to get log level
public
static getLogLevel(int $level) : string
Parameters
- $level : int
Return values
stringgetTimestampFormat()
Get timestamp format
public
getTimestampFormat() : string
Return values
stringgetWriters()
Get all log writers
public
getWriters() : array<string|int, mixed>
Return values
array<string|int, mixed>info()
Add an INFO log entry
public
info(mixed $message[, array<string|int, mixed> $context = [] ]) : Logger
Parameters
- $message : mixed
- $context : array<string|int, mixed> = []
Return values
Loggerlog()
Add a log entry
public
log(mixed $level, mixed $message[, array<string|int, mixed> $context = [] ]) : Logger
Parameters
- $level : mixed
- $message : mixed
- $context : array<string|int, mixed> = []
Return values
Loggernotice()
Add a NOTICE log entry
public
notice(mixed $message[, array<string|int, mixed> $context = [] ]) : Logger
Parameters
- $message : mixed
- $context : array<string|int, mixed> = []
Return values
LoggersetLogLimit()
Set log level limit for all log writers
public
setLogLimit(int $level) : Logger
Parameters
- $level : int
Return values
LoggersetTimestampFormat()
Set timestamp format
public
setTimestampFormat([string $format = 'Y-m-d H:i:s' ]) : Logger
Parameters
- $format : string = 'Y-m-d H:i:s'
Return values
Loggerwarning()
Add a WARNING log entry
public
warning(mixed $message[, array<string|int, mixed> $context = [] ]) : Logger
Parameters
- $message : mixed
- $context : array<string|int, mixed> = []