Skip to content

Commit ba553b6

Browse files
committed
ICL: Laravel 5.2 capability returned.
1 parent 8efddc1 commit ba553b6

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

src/ExceptionHandler.php

+9-10
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,18 @@
44

55
use Exception;
66
use Illuminate\Foundation\Exceptions\Handler;
7+
use Psr\Log\LoggerInterface;
78

89
class ExceptionHandler extends Handler
910
{
10-
private $log;
11+
private $logger;
1112
private $timeStarted;
1213
private $timeFinished;
1314
protected $reservedMemory;
1415

15-
public function __construct()
16+
public function initialize(LoggerInterface $logger)
1617
{
17-
parent::__construct(app());
18-
19-
$this->log = app('log.iclogger');
18+
$this->logger = $logger;
2019
$this->registerShutdownFunction();
2120
}
2221

@@ -36,7 +35,7 @@ public function report(Exception $e)
3635
}
3736
}
3837

39-
$this->log->error($e->getMessage(), $context);
38+
$this->logger->error($e->getMessage(), $context);
4039
}
4140

4241
private function registerShutdownFunction()
@@ -49,14 +48,14 @@ private function registerShutdownFunction()
4948

5049
$this->timeFinished = microtime(true);
5150
$executionTime = round($this->timeFinished - $this->timeStarted, 3);
52-
$this->log->info("Execution time: {$executionTime} sec.");
51+
$this->logger->info("Execution time: {$executionTime} sec.");
5352

5453
$memoryPeak = format_bytes(memory_get_peak_usage(true));
55-
$this->log->info("Memory peak usage: {$memoryPeak}.");
54+
$this->logger->info("Memory peak usage: {$memoryPeak}.");
5655

57-
$this->log->info('%separator%');
56+
$this->logger->info('%separator%');
5857

59-
$handlers = $this->log->getHandlers();
58+
$handlers = $this->logger->getHandlers();
6059
foreach ($handlers as $handler) {
6160
$handler->close();
6261
}

src/Loggable.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ private function initializeErrorHandling()
5454
$this->icLogger = app('log.iclogger');
5555

5656
app()->singleton(ExceptionHandlerContract::class, ExceptionHandler::class);
57-
app(ExceptionHandlerContract::class);
57+
app(ExceptionHandlerContract::class)->initialize($this->icLogger);
5858
}
5959

6060
private function getLogHandlers()

0 commit comments

Comments
 (0)