Version 1
[yaffs-website] / web / core / lib / Drupal / Core / Logger / LoggerChannelInterface.php
1 <?php
2
3 namespace Drupal\Core\Logger;
4
5 use Drupal\Core\Session\AccountInterface;
6 use Psr\Log\LoggerInterface;
7 use Symfony\Component\HttpFoundation\RequestStack;
8
9 /**
10  * Logger channel interface.
11  *
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
15  * methods here).
16  *
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.
22  *
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.
27  *
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()
34  */
35 interface LoggerChannelInterface extends LoggerInterface {
36
37   /**
38    * Sets the request stack.
39    *
40    * @param \Symfony\Component\HttpFoundation\RequestStack|null $requestStack
41    *   The current request object.
42    */
43   public function setRequestStack(RequestStack $requestStack = NULL);
44
45   /**
46    * Sets the current user.
47    *
48    * @param \Drupal\Core\Session\AccountInterface|null $current_user
49    *   The current user object.
50    */
51   public function setCurrentUser(AccountInterface $current_user = NULL);
52
53   /**
54    * Sets the loggers for this channel.
55    *
56    * @param array $loggers
57    *   An array of arrays of \Psr\Log\LoggerInterface keyed by priority.
58    */
59   public function setLoggers(array $loggers);
60
61   /**
62    * Adds a logger.
63    *
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.
68    */
69   public function addLogger(LoggerInterface $logger, $priority = 0);
70
71 }