Logger
class Logger implements LoggerInterface
Traits
Constants
| protected CONTEXT_KEY_PREFIX |
The CoroutineContext key prefix for per-channel logger context. |
Properties
| static protected int | $nextFamilyId | The next worker-unique logger family identifier. |
|
| protected string | $stateKey | The coroutine-local key for this logger channel's context. |
Methods
Apply the callback if the given "value" is (or resolves to) truthy.
Apply the callback if the given "value" is (or resolves to) falsy.
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 log context on all currently resolved channels.
Get the existing context array.
Get the state for this logger family in the current coroutine.
Fire 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
in
Conditionable at line 23
mixed
when(mixed $value = null, callable|null $callback = null, callable|null $default = null)
Apply the callback if the given "value" is (or resolves to) truthy.
in
Conditionable at line 56
mixed
unless(mixed $value = null, callable|null $callback = null, callable|null $default = null)
Apply the callback if the given "value" is (or resolves to) falsy.
at line 48
__construct(LoggerInterface $logger, Dispatcher|null $dispatcher = null)
Create a new log writer instance.
at line 64
void
emergency(Arrayable|Jsonable|Stringable|array|string $message, array $context = [])
Log an emergency message to the logs.
at line 72
void
alert(Arrayable|Jsonable|Stringable|array|string $message, array $context = [])
Log an alert message to the logs.
at line 80
void
critical(Arrayable|Jsonable|Stringable|array|string $message, array $context = [])
Log a critical message to the logs.
at line 88
void
error(Arrayable|Jsonable|Stringable|array|string $message, array $context = [])
Log an error message to the logs.
at line 96
void
warning(Arrayable|Jsonable|Stringable|array|string $message, array $context = [])
Log a warning message to the logs.
at line 104
void
notice(Arrayable|Jsonable|Stringable|array|string $message, array $context = [])
Log a notice to the logs.
at line 112
void
info(Arrayable|Jsonable|Stringable|array|string $message, array $context = [])
Log an informational message to the logs.
at line 120
void
debug(Arrayable|Jsonable|Stringable|array|string $message, array $context = [])
Log a debug message to the logs.
at line 130
void
log(string $level, Arrayable|Jsonable|Stringable|array|string $message, array $context = [])
Log a message to the logs.
at line 138
void
write(string $level, Arrayable|Jsonable|Stringable|array|string $message, array $context = [])
Dynamically pass log calls into the writer.
at line 146
protected void
writeLog(string $level, Arrayable|Jsonable|Stringable|array|string $message, array $context)
Write a message to the log.
at line 185
Logger
withName(string $name)
Return a named variant of the logger.
at line 202
Logger
withContext(array $context = [])
Add context to all future logs.
at line 216
Logger
withoutContext(array|null $keys = null)
Flush the log context on all currently resolved channels.
at line 234
array
getContext()
Get the existing context array.
at line 244
protected LoggerState
state()
Get the state for this logger family in the current coroutine.
at line 260
void
listen(Closure $callback)
Register a new callback handler for when a log event is triggered.
Boot-only. Registers a listener on the worker-global event dispatcher; per-request registration persists and affects subsequent requests.
at line 272
protected void
fireLogEvent(string $level, string $message, array $context = [])
Fire a log event.
at line 295
protected string
formatMessage(Arrayable|Jsonable|Stringable|array|string $message)
Format the parameters for the logger.
at line 308
LoggerInterface
getLogger()
Get the underlying logger implementation.
at line 316
Dispatcher|null
getEventDispatcher()
Get the event dispatcher instance.
at line 327
void
setEventDispatcher(Dispatcher $dispatcher)
Set the event dispatcher instance.
Boot or tests only. Persists on the cached logger for the worker lifetime; per-request use races across coroutines.
at line 339
mixed
__call(string $method, array $parameters)
Dynamically proxy method calls to the underlying logger.