Passed
Push — master ( b5e6ba...9ab7d8 )
by Radu
09:39 queued 02:23
created

LogTrait   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 4
eloc 11
c 2
b 0
f 0
dl 0
loc 40
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A logInfo() 0 4 1
A logWarning() 0 4 1
A logDebug() 0 4 1
A logError() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace WebServCo\Framework\Traits;
6
7
/**
8
* Log simple messages to both file and output.
9
*/
10
trait LogTrait
11
{
12
    protected \WebServCo\Framework\Interfaces\LoggerInterface $fileLogger;
13
    protected \WebServCo\Framework\Interfaces\OutputLoggerInterface $outputLogger;
14
15
    /**
16
    * @param mixed $context
17
    */
18
    protected function logDebug(string $message, $context = []): void
19
    {
20
        $this->outputLogger->debug($message);
21
        $this->fileLogger->debug($message, $context);
22
    }
23
24
    /**
25
    * @param mixed $context
26
    */
27
    protected function logError(string $message, $context = []): void
28
    {
29
        $this->outputLogger->output($message);
30
31
        $this->fileLogger->error($message, $context);
32
    }
33
34
    /**
35
    * @param mixed $context
36
    */
37
    protected function logInfo(string $message, $context = []): void
38
    {
39
        $this->outputLogger->info($message);
40
        $this->fileLogger->info($message, $context);
41
    }
42
43
    /**
44
    * @param mixed $context
45
    */
46
    protected function logWarning(string $message, $context = []): void
47
    {
48
        $this->outputLogger->warning($message);
49
        $this->fileLogger->warning($message, $context);
50
    }
51
}
52