Issues (186)

src/Utils/Logging/QueuedJobLogHandler.php (1 issue)

Labels
Severity
1
<?php
2
3
namespace SilverStripe\FullTextSearch\Utils\Logging;
4
5
use Monolog\Handler\AbstractProcessingHandler;
6
use Monolog\Logger;
7
use Symbiote\QueuedJobs\Services\QueuedJob;
0 ignored issues
show
The type Symbiote\QueuedJobs\Services\QueuedJob was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
9
if (!interface_exists(QueuedJob::class)) {
10
    return;
11
}
12
13
/**
14
 * Handler for logging events into QueuedJob message data
15
 */
16
class QueuedJobLogHandler extends AbstractProcessingHandler
17
{
18
    /**
19
     * Job to log to
20
     *
21
     * @var QueuedJob
22
     */
23
    protected $queuedJob;
24
25
    /**
26
     * @param QueuedJob $queuedJob Job to log to
27
     * @param integer $level  The minimum logging level at which this handler will be triggered
28
     * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
29
     */
30
    public function __construct(QueuedJob $queuedJob, $level = Logger::DEBUG, $bubble = true)
31
    {
32
        parent::__construct($level, $bubble);
33
        $this->setQueuedJob($queuedJob);
34
    }
35
36
    /**
37
     * Set a new queuedjob
38
     *
39
     * @param QueuedJob $queuedJob
40
     */
41
    public function setQueuedJob(QueuedJob $queuedJob)
42
    {
43
        $this->queuedJob = $queuedJob;
44
    }
45
46
    /**
47
     * Get queuedjob
48
     *
49
     * @return QueuedJob
50
     */
51
    public function getQueuedJob()
52
    {
53
        return $this->queuedJob;
54
    }
55
56
    protected function write(array $record)
57
    {
58
        // Write formatted message
59
        $this->getQueuedJob()->addMessage($record['formatted']);
60
    }
61
}
62