|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
|
|
4
|
|
|
namespace Oliverde8\PhpEtlBundle\Services; |
|
5
|
|
|
|
|
6
|
|
|
use Monolog\Handler\AbstractProcessingHandler; |
|
|
|
|
|
|
7
|
|
|
use Monolog\Handler\StreamHandler; |
|
|
|
|
|
|
8
|
|
|
use Monolog\Logger; |
|
|
|
|
|
|
9
|
|
|
use Oliverde8\PhpEtlBundle\Entity\EtlExecution; |
|
10
|
|
|
|
|
11
|
|
|
class ChainExecutionLogger extends AbstractProcessingHandler |
|
12
|
|
|
{ |
|
13
|
|
|
/** @var ChainWorkDirManager */ |
|
14
|
|
|
protected $chainWorkDirManager; |
|
15
|
|
|
|
|
16
|
|
|
protected $level; |
|
17
|
|
|
|
|
18
|
|
|
/** @var EtlExecution */ |
|
19
|
|
|
protected $currentExecution; |
|
20
|
|
|
|
|
21
|
|
|
/** @var AbstractProcessingHandler */ |
|
22
|
|
|
protected $currentStreamHandler; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* ChainExecutionLogger constructor. |
|
26
|
|
|
* |
|
27
|
|
|
* @param ChainProcessorsManager $chainProcessorManager |
|
28
|
|
|
* @param ChainWorkDirManager $chainWorkDirManager |
|
29
|
|
|
* @param string $level |
|
30
|
|
|
*/ |
|
31
|
|
|
public function __construct(ChainWorkDirManager $chainWorkDirManager, string $level = Logger::DEBUG) |
|
32
|
|
|
{ |
|
33
|
|
|
$this->chainWorkDirManager = $chainWorkDirManager; |
|
34
|
|
|
$this->level = $level; |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
|
|
38
|
|
|
protected function write(array $record) |
|
39
|
|
|
{ |
|
40
|
|
|
// TODO Optimize this by moving it into isHandling. |
|
41
|
|
|
if (is_null($this->currentExecution) || is_null($this->currentStreamHandler)) { |
|
42
|
|
|
return; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
$this->currentStreamHandler->write($record); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* @param EtlExecution|null $currentExecution |
|
50
|
|
|
*/ |
|
51
|
|
|
public function setCurrentExecution(?EtlExecution $currentExecution): void |
|
52
|
|
|
{ |
|
53
|
|
|
if ($this->currentStreamHandler) { |
|
54
|
|
|
$this->currentStreamHandler->close(); |
|
55
|
|
|
$this->currentStreamHandler = null; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
$this->currentExecution = $currentExecution; |
|
59
|
|
|
if ($currentExecution) { |
|
60
|
|
|
$logFile = $this->chainWorkDirManager->getWorkDir($currentExecution) . "/execution.log"; |
|
61
|
|
|
$this->currentStreamHandler = new StreamHandler($logFile, $this->level); |
|
62
|
|
|
} |
|
63
|
|
|
} |
|
64
|
|
|
} |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths