friendship ended with social-app. php is my new best friend
at main 1.0 kB view raw
1<?php declare(strict_types = 1); 2 3namespace Contributte\Logging; 4 5use Contributte\Logging\Exceptions\Logical\InvalidStateException; 6use Contributte\Logging\Utils\Utils; 7use Throwable; 8use Tracy\BlueScreen; 9 10/** 11 * BlueScreenFileLogger based on official Tracy\Logger (@copyright David Grudl) 12 * 13 * Log every exception as single html file 14 */ 15class BlueScreenFileLogger extends AbstractLogger implements ILogger 16{ 17 18 /** @var BlueScreen|null */ 19 private $blueScreen; 20 21 public function __construct(string $directory, ?BlueScreen $blueScreen = null) 22 { 23 parent::__construct($directory); 24 $this->blueScreen = $blueScreen; 25 } 26 27 /** 28 * @param mixed $message 29 */ 30 public function log($message, string $priority = ILogger::INFO): void 31 { 32 if (!is_dir($this->directory)) { 33 throw new InvalidStateException('Directory ' . $this->directory . ' is not found or is not directory.'); 34 } 35 36 if ($message instanceof Throwable) { 37 Utils::dumpException($message, $this->getExceptionFile($message), $this->blueScreen); 38 } 39 } 40 41}