-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathdebug.php
87 lines (67 loc) · 2.51 KB
/
debug.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
defined('INSIDE') OR exit('No direct script access allowed');
class Debug {
private $log;
private $count = 0;
public function __construct() {
$this->count = 0;
$this->log = ' <div class="row"><div class="col-md-12">
<table class=\'debug_table\'>
<tr>
<th colspan=\'7\'>Error-Log</th>
</tr>
<tr>
<th>#</th>
<th>Class</th>
<th>Method</th>
<th>Line</th>
<th>Exception</th>
<th>Description</th>
<th>Time</th>
</tr>';
}
function getCount() : int {
return $this->count;
}
/**
* adds a row to the debug-log
* @param $class
* @param $method
* @param $line
* @param $exception
* @param $descr
*/
function addLog($class, $method, $line, $exception, $descr) {
$this->count++;
$this->log .= '<tr><td>' . $this->count . '</td><td>' . $class . '</td><td>' . $method . '</td><td>' . $line . '</td><td>' . $exception . '</td><td>' . $descr . '</td><td>' . time() . '</td>';
}
/**
* stores the error in the database
* @param $class
* @param $method
* @param $line
* @param $exception
* @param $descr
*/
function saveError($class, $method, $line, $exception, $descr) {
$dbConnection = new Database();
$stmt = $dbConnection->prepare('INSERT INTO errors (id, class, method, line, exception, description, time) VALUES (NULL, :class, :method, :line, :exception, :description, \'' . date('Y-m-d H:i:s') . '\')');
$stmt->bindParam(':class', $class);
$stmt->bindParam(':method', $method);
$stmt->bindParam(':line', $line);
$stmt->bindParam(':exception', $exception);
$stmt->bindParam(':description', $descr);
$stmt->execute();
}
/**
* prints the debug-log on the current page
* @codeCoverageIgnore
*/
function printDebugLog() {
$this->log .= '
</table>
</div>
</div>';
echo "<br />" . $this->log;
}
}