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