Skip to content

Commit f36db0d

Browse files
committed
* Add #191
1 parent e18d3d6 commit f36db0d

File tree

4 files changed

+106
-1
lines changed

4 files changed

+106
-1
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
# Version 16.6.0
2+
3+
## Bugfixes
4+
5+
* None
6+
7+
## Features
8+
9+
* Add techdivision/import#191
10+
111
# Version 16.5.5
212

313
## Bugfixes

src/Loggers/ErrorLogHandlerFactory.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
3535
* @link https://github.com/techdivision/import
3636
* @link http://www.techdivision.com
37+
*
38+
* @deprecated use GenericLogHandlerFactory
3739
*/
3840
class ErrorLogHandlerFactory implements HandlerFactoryInterface
3941
{
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
<?php
2+
3+
/**
4+
* TechDivision\Import\Loggers\ErrorLogHandlerFactory
5+
*
6+
* NOTICE OF LICENSE
7+
*
8+
* This source file is subject to the Open Software License (OSL 3.0)
9+
* that is available through the world-wide-web at this URL:
10+
* http://opensource.org/licenses/osl-3.0.php
11+
*
12+
* PHP version 5
13+
*
14+
* @author Martin Eisenführer <[email protected]>
15+
* @copyright 2020 TechDivision GmbH <[email protected]>
16+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17+
* @link https://github.com/techdivision/import
18+
* @link http://www.techdivision.com
19+
*/
20+
21+
namespace TechDivision\Import\Loggers;
22+
23+
use TechDivision\Import\Utils\ConfigurationUtil;
24+
use TechDivision\Import\Utils\ConfigurationKeys;
25+
use TechDivision\Import\Configuration\ConfigurationInterface;
26+
use TechDivision\Import\Configuration\Logger\HandlerConfigurationInterface;
27+
28+
/**
29+
* Error Log Handler factory implementation.
30+
*
31+
* @author Martin Eisenführer <[email protected]>
32+
* @copyright 2020 TechDivision GmbH <[email protected]>
33+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
34+
* @link https://github.com/techdivision/import
35+
* @link http://www.techdivision.com
36+
*/
37+
class GenericLogHandlerFactory implements HandlerFactoryInterface
38+
{
39+
40+
/**
41+
* The log level to use.
42+
*
43+
* @var string
44+
*/
45+
protected $defaultLogLevel;
46+
47+
/**
48+
* The log level to use.
49+
*
50+
* @var string
51+
*/
52+
protected $handlerClassName;
53+
54+
/**
55+
* Initialize the processor with the actual configuration instance
56+
*
57+
* @param ConfigurationInterface $configuration the actual configuration instance
58+
* @param string $handlerClassName Classname for monolog Logger handler
59+
*/
60+
public function __construct(ConfigurationInterface $configuration, $handlerClassName)
61+
{
62+
$this->defaultLogLevel = $configuration->getLogLevel();
63+
$this->handlerClassName = $handlerClassName;
64+
}
65+
66+
/**
67+
* Creates a new formatter instance based on the passed configuration.
68+
*
69+
* @param \TechDivision\Import\Configuration\Logger\HandlerConfigurationInterface $handlerConfiguration The handler configuration
70+
*
71+
* @return \Monolog\Handler\HandlerInterface The handler instance
72+
*/
73+
public function factory(HandlerConfigurationInterface $handlerConfiguration)
74+
{
75+
76+
// load the params
77+
$params = $handlerConfiguration->getParams();
78+
79+
// set the default log level, if not already set explicitly
80+
if (!isset($params[ConfigurationKeys::LEVEL])) {
81+
$params[ConfigurationKeys::LEVEL] = $this->defaultLogLevel;
82+
}
83+
84+
// create and return the handler instance
85+
$reflectionClass = new \ReflectionClass($this->handlerClassName);
86+
return $reflectionClass->newInstanceArgs(ConfigurationUtil::prepareConstructorArgs($reflectionClass, $params));
87+
}
88+
}

symfony/Resources/config/services.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,13 @@
4242
<argument type="service" id="service_container"/>
4343
<argument type="service" id="import.logger.factory.monolog.handler"/>
4444
</service>
45-
<service id="import.logger.factory.handler.error.log" class="TechDivision\Import\Loggers\ErrorLogHandlerFactory" shared="false">
45+
<service id="import.logger.factory.handler.native.mail.log" class="TechDivision\Import\Loggers\GenericLogHandlerFactory" shared="false">
4646
<argument type="service" id="configuration"/>
47+
<argument type="string">Monolog\Handler\NativeMailerHandler</argument>
48+
</service>
49+
<service id="import.logger.factory.handler.error.log" class="TechDivision\Import\Loggers\GenericLogHandlerFactory" shared="false">
50+
<argument type="service" id="configuration"/>
51+
<argument type="string">Monolog\Handler\ErrorLogHandler</argument>
4752
</service>
4853
<service id="import.logger.factory.handler.swift" class="TechDivision\Import\Loggers\SwiftMailerHandlerFactory" shared="false">
4954
<argument type="service" id="service_container"/>

0 commit comments

Comments
 (0)