Passed
Push — master ( f946ea...c739e9 )
by Daimona
02:07
created

SimpleLogger::levelToInt()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 10
nc 1
nop 1
dl 0
loc 13
rs 9.9332
c 0
b 0
f 0
1
<?php declare( strict_types=1 );
2
3
namespace BotRiconferme\Logger;
4
5
use Psr\Log\AbstractLogger;
6
use Psr\Log\LogLevel;
7
8
/**
9
 * Logger that just prints stuff to stdout
10
 */
11
class SimpleLogger extends AbstractLogger {
12
	use LoggerTrait;
13
14
	/** @var int */
15
	private $minLevel;
16
17
	/**
18
	 * @param string $minlevel
19
	 */
20
	public function __construct( $minlevel = LogLevel::INFO ) {
21
		$this->minLevel = $this->levelToInt( $minlevel );
22
	}
23
24
	/**
25
	 * @inheritDoc
26
	 * @suppress PhanUnusedPublicMethodParameter
27
	 */
28
	public function log( $level, $message, array $context = [] ) {
29
		if ( $this->levelToInt( $level ) >= $this->minLevel ) {
30
			echo $this->getFormattedMessage( $level, $message );
31
		}
32
	}
33
}
34