class LogManager implements LoggerInterface mixin Logger (View source)

Traits

Properties

protected array $levels

The Log levels.

from  ParsesLogConfiguration
protected Application $app

The application instance.

protected array $channels

The array of resolved channels.

protected array $sharedContext

The context shared across channels and stacks.

protected array $customCreators

The registered custom driver creators.

protected string $dateFormat

The standard date format to use when writing logs.

Methods

string
getFallbackChannelName()

Get fallback log channel name.

int
level(array $config)

Parse the string level into a Monolog constant.

int
actionLevel(array $config)

Parse the action level from the given configuration.

string
parseChannel(array $config)

Extract the log channel from the given configuration.

void
__construct(Application $app)

Create a new Log manager instance.

LoggerInterface
build(array $config)

Build an on-demand log channel.

LoggerInterface
stack(array $channels, string|null $channel = null)

Create a new, on-demand aggregate logger instance.

LoggerInterface
channel(string|null $channel = null)

Get a log channel instance.

LoggerInterface
driver(string|null $driver = null)

Get a log driver instance.

LoggerInterface
get(string $name, array|null $config = null)

Attempt to get the log from the local cache.

tap(string $name, Logger $logger)

Apply the configured taps for the logger.

array
parseTap(string $tap)

Parse the given tap class string into a class name and arguments string.

LoggerInterface
createEmergencyLogger()

Create an emergency log handler to avoid white screens of death.

LoggerInterface
resolve(string $name, array|null $config = null)

Resolve the given log instance by name.

mixed
callCustomCreator(array $config)

Call a custom driver creator.

LoggerInterface
createCustomDriver(array $config)

Create a custom log driver instance.

LoggerInterface
createStackDriver(array $config)

Create an aggregate log driver instance.

LoggerInterface
createSingleDriver(array $config)

Create an instance of the single file log driver.

LoggerInterface
createDailyDriver(array $config)

Create an instance of the daily file log driver.

LoggerInterface
createSlackDriver(array $config)

Create an instance of the Slack log driver.

LoggerInterface
createSyslogDriver(array $config)

Create an instance of the syslog log driver.

LoggerInterface
createErrorlogDriver(array $config)

Create an instance of the "error log" log driver.

LoggerInterface
createMonologDriver(array $config)

Create an instance of any handler available in Monolog.

array
prepareHandlers(array $handlers)

Prepare the handlers for usage by Monolog.

HandlerInterface
prepareHandler(HandlerInterface $handler, array $config = [])

Prepare the handler for usage by Monolog.

FormatterInterface
formatter()

Get a Monolog formatter instance.

$this
shareContext(array $context)

Share context across channels and stacks.

array
sharedContext()

The context shared across channels and stacks.

$this
flushSharedContext()

Flush the shared context.

array
configurationFor(string $name)

Get the log connection configuration.

string|null
getDefaultDriver()

Get the default log driver name.

void
setDefaultDriver(string $name)

Set the default log driver name.

$this
extend(string $driver, Closure $callback)

Register a custom driver creator Closure.

void
forgetChannel(string|null $driver = null)

Unset the given channel instance.

string|null
parseDriver(string|null $driver)

Parse the driver name.

array
getChannels()

Get all of the resolved log channels.

void
emergency(string $message, array $context = [])

System is unusable.

void
alert(string $message, array $context = [])

Action must be taken immediately.

void
critical(string $message, array $context = [])

Critical conditions.

void
error(string $message, array $context = [])

Runtime errors that do not require immediate action but should typically be logged and monitored.

void
warning(string $message, array $context = [])

Exceptional occurrences that are not errors.

void
notice(string $message, array $context = [])

Normal but significant events.

void
info(string $message, array $context = [])

Interesting events.

void
debug(string $message, array $context = [])

Detailed debug information.

void
log(mixed $level, string $message, array $context = [])

Logs with an arbitrary level.

mixed
__call(string $method, array $parameters)

Dynamically call the default driver instance.

Details

protected string getFallbackChannelName()

Get fallback log channel name.

Return Value

string

protected int level(array $config)

Parse the string level into a Monolog constant.

Parameters

array $config

Return Value

int

Exceptions

InvalidArgumentException

protected int actionLevel(array $config)

Parse the action level from the given configuration.

Parameters

array $config

Return Value

int

protected string parseChannel(array $config)

Extract the log channel from the given configuration.

Parameters

array $config

Return Value

string

void __construct(Application $app)

Create a new Log manager instance.

Parameters

Application $app

Return Value

void

LoggerInterface build(array $config)

Build an on-demand log channel.

Parameters

array $config

Return Value

LoggerInterface

LoggerInterface stack(array $channels, string|null $channel = null)

Create a new, on-demand aggregate logger instance.

Parameters

array $channels
string|null $channel

Return Value

LoggerInterface

LoggerInterface channel(string|null $channel = null)

Get a log channel instance.

Parameters

string|null $channel

Return Value

LoggerInterface

LoggerInterface driver(string|null $driver = null)

Get a log driver instance.

Parameters

string|null $driver

Return Value

LoggerInterface

protected LoggerInterface get(string $name, array|null $config = null)

Attempt to get the log from the local cache.

Parameters

string $name
array|null $config

Return Value

LoggerInterface

protected Logger tap(string $name, Logger $logger)

Apply the configured taps for the logger.

Parameters

string $name
Logger $logger

Return Value

Logger

protected array parseTap(string $tap)

Parse the given tap class string into a class name and arguments string.

Parameters

string $tap

Return Value

array

protected LoggerInterface createEmergencyLogger()

Create an emergency log handler to avoid white screens of death.

Return Value

LoggerInterface

protected LoggerInterface resolve(string $name, array|null $config = null)

Resolve the given log instance by name.

Parameters

string $name
array|null $config

Return Value

LoggerInterface

Exceptions

InvalidArgumentException

protected mixed callCustomCreator(array $config)

Call a custom driver creator.

Parameters

array $config

Return Value

mixed

protected LoggerInterface createCustomDriver(array $config)

Create a custom log driver instance.

Parameters

array $config

Return Value

LoggerInterface

protected LoggerInterface createStackDriver(array $config)

Create an aggregate log driver instance.

Parameters

array $config

Return Value

LoggerInterface

protected LoggerInterface createSingleDriver(array $config)

Create an instance of the single file log driver.

Parameters

array $config

Return Value

LoggerInterface

protected LoggerInterface createDailyDriver(array $config)

Create an instance of the daily file log driver.

Parameters

array $config

Return Value

LoggerInterface

protected LoggerInterface createSlackDriver(array $config)

Create an instance of the Slack log driver.

Parameters

array $config

Return Value

LoggerInterface

protected LoggerInterface createSyslogDriver(array $config)

Create an instance of the syslog log driver.

Parameters

array $config

Return Value

LoggerInterface

protected LoggerInterface createErrorlogDriver(array $config)

Create an instance of the "error log" log driver.

Parameters

array $config

Return Value

LoggerInterface

protected LoggerInterface createMonologDriver(array $config)

Create an instance of any handler available in Monolog.

Parameters

array $config

Return Value

LoggerInterface

Exceptions

InvalidArgumentException
BindingResolutionException

protected array prepareHandlers(array $handlers)

Prepare the handlers for usage by Monolog.

Parameters

array $handlers

Return Value

array

protected HandlerInterface prepareHandler(HandlerInterface $handler, array $config = [])

Prepare the handler for usage by Monolog.

Parameters

HandlerInterface $handler
array $config

Return Value

HandlerInterface

protected FormatterInterface formatter()

Get a Monolog formatter instance.

Return Value

FormatterInterface

$this shareContext(array $context)

Share context across channels and stacks.

Parameters

array $context

Return Value

$this

array sharedContext()

The context shared across channels and stacks.

Return Value

array

$this flushSharedContext()

Flush the shared context.

Return Value

$this

protected array configurationFor(string $name)

Get the log connection configuration.

Parameters

string $name

Return Value

array

string|null getDefaultDriver()

Get the default log driver name.

Return Value

string|null

void setDefaultDriver(string $name)

Set the default log driver name.

Parameters

string $name

Return Value

void

$this extend(string $driver, Closure $callback)

Register a custom driver creator Closure.

Parameters

string $driver
Closure $callback

Return Value

$this

void forgetChannel(string|null $driver = null)

Unset the given channel instance.

Parameters

string|null $driver

Return Value

void

protected string|null parseDriver(string|null $driver)

Parse the driver name.

Parameters

string|null $driver

Return Value

string|null

array getChannels()

Get all of the resolved log channels.

Return Value

array

void emergency(string $message, array $context = [])

System is unusable.

Parameters

string $message
array $context

Return Value

void

void alert(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.

Parameters

string $message
array $context

Return Value

void

void critical(string $message, array $context = [])

Critical conditions.

Example: Application component unavailable, unexpected exception.

Parameters

string $message
array $context

Return Value

void

void error(string $message, array $context = [])

Runtime errors that do not require immediate action but should typically be logged and monitored.

Parameters

string $message
array $context

Return Value

void

void warning(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.

Parameters

string $message
array $context

Return Value

void

void notice(string $message, array $context = [])

Normal but significant events.

Parameters

string $message
array $context

Return Value

void

void info(string $message, array $context = [])

Interesting events.

Example: User logs in, SQL logs.

Parameters

string $message
array $context

Return Value

void

void debug(string $message, array $context = [])

Detailed debug information.

Parameters

string $message
array $context

Return Value

void

void log(mixed $level, string $message, array $context = [])

Logs with an arbitrary level.

Parameters

mixed $level
string $message
array $context

Return Value

void

mixed __call(string $method, array $parameters)

Dynamically call the default driver instance.

Parameters

string $method
array $parameters

Return Value

mixed