-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDebug.php
84 lines (66 loc) · 1.43 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
<?php
/**
* @fileoverview Debugging
* @author Vincent Thibault (alias KeyWorld - Twitter: @robrowser)
* @version 1.0.0
*/
final class Debug
{
static private $messages = array();
static private $actived = false;
/**
* Add a message to the list
*
* @param {string} message to display
* @param {string} optional class
*/
static public function write($message, $class='')
{
self::$messages[] = '<div class="'.$class.'">'. $message . '</div>';
}
/**
* Enable
*/
static public function enable()
{
ini_set('display_errors', 1);
error_reporting(E_ALL);
self::$actived = true;
}
/**
* Disable debug mode
*/
static public function disable()
{
ini_set('display_errors', 0);
error_reporting(-1);
self::$actived = false;
}
/**
* Is in debug mode ?
*
* @return {boolean}
*/
static public function isEnable()
{
return self::$actived;
}
/**
* Output the log
*/
static public function output() {
if (self::$actived) {
header('Content-type:text/html');
echo '<style type="text/css">';
echo '.info { color:#c50; }';
echo '.error { color:#f00; font-weight:bold; }';
echo '.success { color:#080; }';
echo '.title { margin-top:20px; font-weight:bold; color: #05A; }';
echo '</style>';
echo '<h1>Debug Trace</h1>';
echo implode('', self::$messages);
echo '<p><em>Make sure to turn off the debug mode in configs.php once successfully configured.</em></p>';
}
exit();
}
}