LogChannel
class LogChannel extends LogManager
Traits
Constants
| protected SHARED_CONTEXT_KEY |
Context key for shared log context across channels. |
Properties
| protected array | $levels | The Log levels. |
from ParsesLogConfiguration |
| protected array | $channels | The array of resolved channels. |
from LogManager |
| protected array | $customCreators | The registered custom driver creators. |
from LogManager |
| protected string | $dateFormat | The standard date format to use when writing logs. |
from LogManager |
Methods
Parse the string level into a Monolog constant.
Parse the action level from the given configuration.
Extract the log channel from the given configuration.
Create a new, on-demand aggregate logger instance.
Get a log channel instance.
Get a log driver instance.
Attempt to get the log from the local cache.
Create a configured logger, optionally retaining a named channel.
Parse the given tap class string into a class name and arguments string.
Create an emergency log handler to avoid white screens of death.
Resolve the given log instance by name.
Create a custom log driver instance.
Create an aggregate log driver instance.
Create an instance of the single file log driver.
Create an instance of the daily file log driver.
Create an instance of the Slack log driver.
Create an instance of the syslog log driver.
Create an instance of the "error log" log driver.
Create an instance of any handler available in Monolog.
Prepare the handler for usage by Monolog.
Create a wrapped context log processor.
Flush the log context on all currently resolved channels.
Get the log connection configuration.
System is unusable.
Action must be taken immediately.
Critical conditions.
Runtime errors that do not require immediate action but should typically be logged and monitored.
Exceptional occurrences that are not errors.
Normal but significant events.
Detailed debug information.
Logs with an arbitrary level.
Dynamically call the default driver instance.
Create the Sentry logs channel.
Details
in
ParsesLogConfiguration at line 29
abstract protected string
getFallbackChannelName()
Get fallback log channel name.
in
ParsesLogConfiguration at line 36
protected Level
level(array $config)
Parse the string level into a Monolog constant.
in
ParsesLogConfiguration at line 52
protected Level
actionLevel(array $config)
Parse the action level from the given configuration.
in
ParsesLogConfiguration at line 66
protected string
parseChannel(array $config)
Extract the log channel from the given configuration.
in
RebindsCallbacksToSelf at line 18
protected Closure|null
bindCallbackToSelf(Closure $callback)
Bind the provided callback to the class instance.
in
LogManager at line 75
__construct(Application $app)
Create a new Log manager instance.
in
LogManager at line 83
LoggerInterface
build(array $config)
Build an on-demand log channel.
in
LogManager at line 91
LoggerInterface
stack(array $channels, string|null $channel = null)
Create a new, on-demand aggregate logger instance.
in
LogManager at line 113
LoggerInterface
channel(UnitEnum|string|null $channel = null)
Get a log channel instance.
in
LogManager at line 121
LoggerInterface
driver(UnitEnum|string|null $driver = null)
Get a log driver instance.
in
LogManager at line 133
protected LoggerInterface
get(string|null $name, array|null $config = null)
Attempt to get the log from the local cache.
in
LogManager at line 145
protected LoggerInterface
createLogger(string|null $name, array|null $config = null, bool $cache = false)
Create a configured logger, optionally retaining a named channel.
in
LogManager at line 182
protected Logger
tap(array $config, Logger $logger)
Apply the configured taps for the logger.
in
LogManager at line 196
protected array
parseTap(string $tap)
Parse the given tap class string into a class name and arguments string.
in
LogManager at line 204
protected LoggerInterface
createEmergencyLogger()
Create an emergency log handler to avoid white screens of death.
in
LogManager at line 224
protected LoggerInterface
resolve(string|null $name, array $config)
Resolve the given log instance by name.
in
LogManager at line 242
protected mixed
callCustomCreator(array $config)
Call a custom driver creator.
in
LogManager at line 250
protected LoggerInterface
createCustomDriver(array $config)
Create a custom log driver instance.
in
LogManager at line 260
protected LoggerInterface
createStackDriver(array $config)
Create an aggregate log driver instance.
in
LogManager at line 291
protected LoggerInterface
createSingleDriver(array $config)
Create an instance of the single file log driver.
in
LogManager at line 310
protected LoggerInterface
createDailyDriver(array $config)
Create an instance of the daily file log driver.
in
LogManager at line 327
protected LoggerInterface
createSlackDriver(array $config)
Create an instance of the Slack log driver.
in
LogManager at line 348
protected LoggerInterface
createSyslogDriver(array $config)
Create an instance of the syslog log driver.
in
LogManager at line 362
protected LoggerInterface
createErrorlogDriver(array $config)
Create an instance of the "error log" log driver.
in
LogManager at line 377
protected LoggerInterface
createMonologDriver(array $config)
Create an instance of any handler available in Monolog.
in
LogManager at line 435
protected array
prepareHandlers(array $handlers)
Prepare the handlers for usage by Monolog.
in
LogManager at line 447
protected HandlerInterface
prepareHandler(HandlerInterface $handler, array $config = [])
Prepare the handler for usage by Monolog.
in
LogManager at line 475
protected FormatterInterface
formatter()
Get a Monolog formatter instance.
in
LogManager at line 487
protected ResolvedContextLogProcessor
makeContextProcessor()
Create a wrapped context log processor.
Wrapping in ResolvedContextLogProcessor allows createStackDriver() to filter out context processors from constituent channels regardless of how the processor was bound (class, closure, or custom callable).
in
LogManager at line 499
LogManager
shareContext(array $context)
Share context across channels and stacks.
in
LogManager at line 515
array
sharedContext()
The context shared across channels and stacks.
in
LogManager at line 526
LogManager
withoutContext(array|null $keys = null)
Flush the log context on all currently resolved channels.
in
LogManager at line 542
LogManager
flushSharedContext()
Flush the shared context.
in
LogManager at line 560
protected array|null
configurationFor(string|null $name)
Get the log connection configuration.
in
LogManager at line 568
string|null
getDefaultDriver()
Get the default log driver name.
in
LogManager at line 578
void
setDefaultDriver(UnitEnum|string $name)
Set the default log driver name.
Boot-only. Mutates process-global config; per-request use races across coroutines.
in
LogManager at line 595
LogManager
extend(string $driver, Closure $callback)
Register a custom driver creator Closure.
Boot-only. The callback persists in the singleton's customCreators array for the worker lifetime and applies to every subsequent channel resolution.
in
LogManager at line 616
void
forgetChannel(string|null $driver = null)
Unset the given channel instance.
Boot or tests only. Mutates the singleton's channel cache; concurrent coroutines may already hold a reference to the channel and next resolution will rebuild with fresh handlers (file handles, etc.).
in
LogManager at line 628
protected string|null
parseDriver(string|null $driver)
Parse the driver name.
in
LogManager at line 646
array
getChannels()
Get all of the resolved log channels.
in
LogManager at line 654
void
emergency(Arrayable|Jsonable|Stringable|array|string $message, array $context = [])
System is unusable.
in
LogManager at line 665
void
alert(Arrayable|Jsonable|Stringable|array|string $message, array $context = [])
Action must be taken immediately.
Example: Entire website down, database unavailable, etc. This should trigger the SMS alerts and wake you up.
in
LogManager at line 675
void
critical(Arrayable|Jsonable|Stringable|array|string $message, array $context = [])
Critical conditions.
Example: Application component unavailable, unexpected exception.
in
LogManager at line 684
void
error(Arrayable|Jsonable|Stringable|array|string $message, array $context = [])
Runtime errors that do not require immediate action but should typically be logged and monitored.
in
LogManager at line 695
void
warning(Arrayable|Jsonable|Stringable|array|string $message, array $context = [])
Exceptional occurrences that are not errors.
Example: Use of deprecated APIs, poor use of an API, undesirable things that are not necessarily wrong.
in
LogManager at line 703
void
notice(Arrayable|Jsonable|Stringable|array|string $message, array $context = [])
Normal but significant events.
in
LogManager at line 713
void
info(Arrayable|Jsonable|Stringable|array|string $message, array $context = [])
Interesting events.
Example: User logs in, SQL logs.
in
LogManager at line 721
void
debug(Arrayable|Jsonable|Stringable|array|string $message, array $context = [])
Detailed debug information.
in
LogManager at line 731
void
log(string $level, Arrayable|Jsonable|Stringable|array|string $message, array $context = [])
Logs with an arbitrary level.
in
LogManager at line 745
LogManager
setApplication(Application $app)
Set the application instance used by the manager.
Tests only. Swaps the singleton's Application reference; per-request use races across coroutines and breaks every concurrent request resolving services through this manager.
in
LogManager at line 759
mixed
__call(string $method, array $parameters)
Dynamically call the default driver instance.
at line 15
Logger
__invoke(array $config = [])
Create the Sentry logs channel.