Monolog::write()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: arnaud
5
 * Date: 04/11/15
6
 * Time: 20:13
7
 */
8
9
namespace Ndrx\Profiler\Components\Logs;
10
11
use Monolog\Handler\AbstractProcessingHandler;
12
use Ndrx\Profiler\Events\DispatcherAwareInterface;
13
use Ndrx\Profiler\Events\DispatcherAwareTrait;
14
use Ndrx\Profiler\Events\Log;
15
use Psr\Log\LoggerInterface;
16
use Psr\Log\LoggerTrait;
17
18
class Monolog extends AbstractProcessingHandler implements DispatcherAwareInterface, LoggerInterface
19
{
20
    use DispatcherAwareTrait, LoggerTrait;
21
22
    /**
23
     * Logs with an arbitrary level.
24
     *
25
     * @param mixed $level
26
     * @param string $message
27
     * @param array $context
28
     * @return null
29
     */
30 2
    public function log($level, $message, array $context = array())
31
    {
32 2
        $this->dispatcher->dispatch(Log::EVENT_NAME, new Log($level, $message, $context, []));
33 2
    }
34
35
    /**
36
     * Writes the record down to the log of the implementing handler
37
     *
38
     * @param  array $record
39
     * @return void
40
     */
41 2
    protected function write(array $record)
42
    {
43 2
        $this->log($record['level'], $record['message']);
44 2
    }
45
}
46