friendship ended with social-app. php is my new best friend
1<?php declare(strict_types = 1);
2
3namespace Contributte\Logging\Utils;
4
5use Throwable;
6use Tracy\BlueScreen;
7
8/**
9 * Based on official Tracy\Logger (@copyright David Grudl)
10 */
11final class Utils
12{
13
14 public static function dumpException(Throwable $exception, string $file, ?BlueScreen $blueScreen = null): string
15 {
16 $bs = $blueScreen ?? new BlueScreen();
17 $bs->renderToFile($exception, $file);
18
19 return $file;
20 }
21
22 public static function captureException(Throwable $exception, string $file, ?BlueScreen $blueScreen = null): string
23 {
24 $bs = $blueScreen ?? new BlueScreen();
25
26 ob_start();
27 $bs->renderToFile($exception, $file);
28 $contents = ob_get_contents();
29
30 return (string) $contents;
31 }
32
33}