Completed
Push — master ( 4c7c03...701d94 )
by Mahmoud
03:31
created

RequestsLogger::prepareLogger()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 1
eloc 5
nc 1
nop 0
1
<?php
2
3
namespace App\Containers\Debugger\Objects;
4
5
use App;
6
use Config;
7
use DB;
8
use Log;
9
use Monolog\Formatter\LineFormatter;
10
use Monolog\Handler\StreamHandler;
11
use Monolog\Logger;
12
13
/**
14
 * Class RequestsLogger
15
 *
16
 * @author  Mahmoud Zalt  <[email protected]>
17
 */
18
class RequestsLogger
19
{
20
21
    CONST TESTING_ENV = 'testing';
22
23
    protected $debuggingEnabled;
24
25
    protected $environment;
26
27
    protected $logger;
28
29
    protected $logFile;
30
31
    /**
32
     * RequestsLogger constructor.
33
     */
34
    public function __construct()
35
    {
36
        $this->prepareConfigs();
37
        $this->prepareLogger();
38
    }
39
40
    /**
41
     * @param \App\Containers\Debugger\Objects\Output $output
42
     */
43
    public function releaseOutput(Output $output)
44
    {
45
        if ($this->environment != self::TESTING_ENV && $this->debuggingEnabled === true) {
46
            $this->logger->info($output->get());
47
        }
48
    }
49
50
    /**
51
     * @void
52
     */
53
    private function prepareConfigs()
54
    {
55
        $this->environment = App::environment();
56
        $this->debuggingEnabled = Config::get("debugger.requests.debug");
57
        $this->logFile = Config::get("debugger.requests.log_file");
58
    }
59
60
    /**
61
     * @void
62
     */
63
    private function prepareLogger()
64
    {
65
        $handler = new StreamHandler(storage_path('logs/' . $this->logFile));
66
        $handler->setFormatter(new LineFormatter(null, null, true, true));
67
68
        $this->logger = new Logger("REQUESTS DEBUGGER");
69
        $this->logger->pushHandler($handler, Logger::INFO);
0 ignored issues
show
Unused Code introduced by
The call to Logger::pushHandler() has too many arguments starting with \Monolog\Logger::INFO.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
70
    }
71
}
72