File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change 7
7
8
8
class ExceptionHandler extends Handler
9
9
{
10
+ private $ timeStarted ;
11
+ private $ timeFinished ;
10
12
protected $ reservedMemory ;
11
13
12
14
public function __construct ()
@@ -28,13 +30,20 @@ public function report(Exception $e)
28
30
29
31
private function registerShutdownFunction ()
30
32
{
33
+ $ this ->timeStarted = microtime (true );
31
34
$ this ->reservedMemory = str_repeat (' ' , 20 * 1024 );
32
35
33
36
register_shutdown_function (function () {
34
37
$ this ->reservedMemory = null ;
35
38
36
- $ this ->log ->info ('Execution time: trash. ' );
37
- $ this ->log ->info ('Memory peak usage: trash. ' );
39
+ $ this ->timeFinished = microtime (true );
40
+ $ executionTime = round ($ this ->timeFinished - $ this ->timeStarted , 3 );
41
+ $ this ->log ->info ("Execution time: {$ executionTime } sec. " );
42
+
43
+ $ memoryPeak = round (memory_get_peak_usage (true ) / (1024 * 1024 ));
44
+ $ this ->log ->info ("Memory peak usage: {$ memoryPeak }M. " );
45
+
46
+ $ this ->log ->info ('%separator% ' );
38
47
39
48
$ handlers = $ this ->log ->getHandlers ();
40
49
foreach ($ handlers as $ handler ) {
Original file line number Diff line number Diff line change @@ -13,6 +13,10 @@ public function __construct()
13
13
14
14
public function format (array $ record )
15
15
{
16
+ if ($ record ['message ' ] == '%separator% ' ) {
17
+ return str_repeat ("\n" , 11 );
18
+ }
19
+
16
20
$ output = parent ::format ($ record );
17
21
return rtrim ($ output ) . "\n" ;
18
22
}
You can’t perform that action at this time.
0 commit comments