Passed
Pull Request — master (#2028)
by Gabriel
203:46 queued 138:41
created

ErrbitLoggerFactory::createErrbitHandler()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 6
c 1
b 0
f 0
nc 1
nop 6
dl 0
loc 9
rs 10
1
<?php
2
declare( strict_types=1 );
3
4
namespace WMDE\Fundraising\Frontend\Factories;
5
6
use Airbrake\MonologHandler as AirbrakeHandler;
7
use Airbrake\Notifier;
8
use Monolog\Handler\HandlerInterface;
9
use Monolog\Logger;
10
use Psr\Log\LogLevel;
11
12
class ErrbitLoggerFactory {
13
	public static function createErrbitHandler( string $projectId, string $projectKey, string $host, string $environment = 'dev', ?string $level = LogLevel::DEBUG, bool $bubble = true ): HandlerInterface {
14
		$notifier = new Notifier( [
15
			'projectId' => $projectId,
16
			'projectKey' => $projectKey,
17
			'host' => $host,
18
			'environment' => $environment
19
		] );
20
21
		return new AirbrakeHandler( $notifier, Logger::toMonologLevel( $level ?? LogLevel::DEBUG ), $bubble );
22
	}
23
24
}
25