/
AbstractLoggerWrapper.php
43 lines (38 loc) · 1.26 KB
/
AbstractLoggerWrapper.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
namespace Lucinda\Logging;
/**
* Implements an abstract converter from an XML line (child of loggers.{environment}) to a Logger instance @ LoggingAPI
*/
abstract class AbstractLoggerWrapper
{
protected Logger $logger;
protected RequestInformation $requestInformation;
/**
* Calls children to return a \Lucinda\Logger instance from matching "logger" XML tag
*
* @param \SimpleXMLElement $xml XML tag that is child of loggers.(environment)
* @throws ConfigurationException
*/
public function __construct(\SimpleXMLElement $xml, RequestInformation $requestInformation)
{
$this->requestInformation = $requestInformation;
$this->logger = $this->setLogger($xml);
}
/**
* Detects Logger instance based on XML tag supplied
*
* @param \SimpleXMLElement $xml XML tag that is child of loggers.(environment)
* @return Logger
* @throws ConfigurationException If resources referenced in XML do not exist or do not extend/implement required blueprint.
*/
abstract protected function setLogger(\SimpleXMLElement $xml): Logger;
/**
* Gets detected logger
*
* @return Logger
*/
public function getLogger(): Logger
{
return $this->logger;
}
}