interface LoggerChannelInterface implements LoggerInterface (View source)

Logger channel interface.

This interface defines the full behavior of the central Drupal logger facility. However, when writing code that does logging, use the generic \Psr\Log\LoggerInterface for typehinting instead (you shouldn't need the methods here).

To add a new logger to the system, implement \Psr\Log\LoggerInterface and add a service for that class to a services.yml file tagged with the 'logger' tag. The default logger channel implementation will call the log() method of every logger service with some useful data set in the $context argument of log(): request_uri, referer, ip, user, uid.

SECURITY NOTE: the caller might also set a 'link' in the $context array which will be printed as-is by the dblog module under an "operations" header. Usually this is a "view", "edit" or similar relevant link. Make sure to use proper, secure link generation facilities; some are listed below.

Methods

setRequestStack(RequestStack $requestStack = NULL)

Sets the request stack.

setCurrentUser(AccountInterface $current_user = NULL)

Sets the current user.

setLoggers(array $loggers)

Sets the loggers for this channel.

addLogger(LoggerInterface $logger, int $priority = 0)

Adds a logger.

Details

setRequestStack(RequestStack $requestStack = NULL)

Sets the request stack.

Parameters

RequestStack $requestStack

The current request object.

setCurrentUser(AccountInterface $current_user = NULL)

Sets the current user.

Parameters

AccountInterface $current_user

The current user object.

setLoggers(array $loggers)

Sets the loggers for this channel.

Parameters

array $loggers

An array of arrays of \Psr\Log\LoggerInterface keyed by priority.

addLogger(LoggerInterface $logger, int $priority = 0)

Adds a logger.

Parameters

LoggerInterface $logger

The PSR-3 logger to add.

int $priority

The priority of the logger being added.