3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
15 * The LogManager will provide instances of "LoggerInterface".
21 const DEFAULT_LOGGER
= 'psr_log';
23 private $channels = [];
26 * Find or create a logger.
28 * This implementation will look for a service "log.{NAME}". If none is defined,
29 * then it will fallback to the "psr_log" service.
31 * @param string $channel
32 * Symbolic name of the intended log.
33 * This should correlate to a service "log.{NAME}".
35 * @return \Psr\Log\LoggerInterface
37 public function getLog($channel = 'default') {
38 if (!isset($this->channels
[$channel])) {
39 $c = \Civi
::container();
40 $svc = "log." . $channel;
41 $this->channels
[$channel] = $c->has($svc) ?
$c->get($svc) : $c->get(self
::DEFAULT_LOGGER
);
43 return $this->channels
[$channel];