Completed
Push — master ( 8a4ca9...acd23c )
by Marco
02:46
created

src/Log/EcontrolLogger.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php namespace Comodojo\Extender\Log;
2
3
use \Monolog\Logger;
4
use \Monolog\Handler\NullHandler;
5
use \Comodojo\Extender\Log\ConsoleHandler;
6
7
/**
8
 * Create a logger instance for econtrol
9
 * 
10
 * @package     Comodojo extender
11
 * @author      Marco Giovinazzi <[email protected]>
12
 * @license     GPL-3.0+
13
 *
14
 * LICENSE:
15
 * 
16
 * This program is free software: you can redistribute it and/or modify
17
 * it under the terms of the GNU Affero General Public License as
18
 * published by the Free Software Foundation, either version 3 of the
19
 * License, or (at your option) any later version.
20
 *
21
 * This program is distributed in the hope that it will be useful,
22
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24
 * GNU Affero General Public License for more details.
25
 *
26
 * You should have received a copy of the GNU Affero General Public License
27
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
28
 */
29
30
class EcontrolLogger extends LogWrapper {
31
32
    /**
33
     * Create the logger
34
     *
35
     * @param string $level
36
     *
37
     * @return \Monolog\Logger
38
     */
39 3
    public static function create($level = false) {
40
41 3
        $logger = new Logger("econtrol");
42
43 3 View Code Duplication
        if ( empty($level) ) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
44
45
            $logger->pushHandler(new NullHandler(self::getLevel("ERROR")));
46
47
        } else {
48
49 3
            $logger->pushHandler(new ConsoleHandler(self::getLevel($level)));
50
51
        }
52
53 3
        return $logger;
54
55
    }
56
57
}