3 namespace Drupal\Core\Logger;
5 use Drupal\Core\Session\AccountInterface;
6 use Psr\Log\LoggerInterface;
7 use Symfony\Component\HttpFoundation\RequestStack;
10 * Logger channel interface.
12 * This interface defines the full behavior of the central Drupal logger
13 * facility. However, when writing code that does logging, use the generic
14 * \Psr\Log\LoggerInterface for typehinting instead (you shouldn't need the
17 * To add a new logger to the system, implement \Psr\Log\LoggerInterface and
18 * add a service for that class to a services.yml file tagged with the 'logger'
19 * tag. The default logger channel implementation will call the log() method
20 * of every logger service with some useful data set in the $context argument
21 * of log(): request_uri, referer, ip, user, uid.
23 * SECURITY NOTE: the caller might also set a 'link' in the $context array
24 * which will be printed as-is by the dblog module under an "operations"
25 * header. Usually this is a "view", "edit" or similar relevant link. Make sure
26 * to use proper, secure link generation facilities; some are listed below.
28 * @see \Drupal\Core\Logger\RfcLoggerTrait
29 * @see \Psr\Log\LoggerInterface
30 * @see \Drupal\Core\Logger\\LoggerChannelFactoryInterface
31 * @see \Drupal\Core\Utility\LinkGeneratorInterface
32 * @see \Drupal\Core\Routing\LinkGeneratorTrait::l()
33 * @see \Drupal\Core\Entity\EntityInterface::link()
35 interface LoggerChannelInterface extends LoggerInterface {
38 * Sets the request stack.
40 * @param \Symfony\Component\HttpFoundation\RequestStack|null $requestStack
41 * The current request object.
43 public function setRequestStack(RequestStack $requestStack = NULL);
46 * Sets the current user.
48 * @param \Drupal\Core\Session\AccountInterface|null $current_user
49 * The current user object.
51 public function setCurrentUser(AccountInterface $current_user = NULL);
54 * Sets the loggers for this channel.
56 * @param array $loggers
57 * An array of arrays of \Psr\Log\LoggerInterface keyed by priority.
59 public function setLoggers(array $loggers);
64 * @param \Psr\Log\LoggerInterface $logger
65 * The PSR-3 logger to add.
66 * @param int $priority
67 * The priority of the logger being added.
69 public function addLogger(LoggerInterface $logger, $priority = 0);