Logger
class Logger implements LoggerInterface (View source)
Properties
protected LoggerInterface | $logger | The underlying logger implementation. |
|
protected Dispatcher|null | $dispatcher | The event dispatcher instance. |
|
protected array | $context | Any context to be added to logs. |
Methods
Create a new log writer instance.
Log an emergency message to the logs.
Log an alert message to the logs.
Log a critical message to the logs.
Log an error message to the logs.
Log a warning message to the logs.
Log a notice to the logs.
Log an informational message to the logs.
Log a debug message to the logs.
Log a message to the logs.
Dynamically pass log calls into the writer.
Write a message to the log.
Add context to all future logs.
Flush the existing context array.
Fires a log event.
Format the parameters for the logger.
Get the underlying logger implementation.
Get the event dispatcher instance.
Dynamically proxy method calls to the underlying logger.
Details
void
__construct(LoggerInterface $logger, Dispatcher $dispatcher = null)
Create a new log writer instance.
void
emergency(Arrayable|Jsonable|Stringable|array|string $message, array $context = [])
Log an emergency message to the logs.
void
alert(Arrayable|Jsonable|Stringable|array|string $message, array $context = [])
Log an alert message to the logs.
void
critical(Arrayable|Jsonable|Stringable|array|string $message, array $context = [])
Log a critical message to the logs.
void
error(Arrayable|Jsonable|Stringable|array|string $message, array $context = [])
Log an error message to the logs.
void
warning(Arrayable|Jsonable|Stringable|array|string $message, array $context = [])
Log a warning message to the logs.
void
notice(Arrayable|Jsonable|Stringable|array|string $message, array $context = [])
Log a notice to the logs.
void
info(Arrayable|Jsonable|Stringable|array|string $message, array $context = [])
Log an informational message to the logs.
void
debug(Arrayable|Jsonable|Stringable|array|string $message, array $context = [])
Log a debug message to the logs.
void
log(string $level, Arrayable|Jsonable|Stringable|array|string $message, array $context = [])
Log a message to the logs.
void
write(string $level, Arrayable|Jsonable|Stringable|array|string $message, array $context = [])
Dynamically pass log calls into the writer.
protected void
writeLog(string $level, Arrayable|Jsonable|Stringable|array|string $message, array $context)
Write a message to the log.
$this
withContext(array $context = [])
Add context to all future logs.
$this
withoutContext()
Flush the existing context array.
void
listen(Closure $callback)
Register a new callback handler for when a log event is triggered.
protected void
fireLogEvent(string $level, string $message, array $context = [])
Fires a log event.
protected string
formatMessage(Arrayable|Jsonable|Stringable|array|string $message)
Format the parameters for the logger.
LoggerInterface
getLogger()
Get the underlying logger implementation.
Dispatcher
getEventDispatcher()
Get the event dispatcher instance.
void
setEventDispatcher(Dispatcher $dispatcher)
Set the event dispatcher instance.
mixed
__call(string $method, array $parameters)
Dynamically proxy method calls to the underlying logger.