-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDebug.php
More file actions
48 lines (33 loc) · 1 KB
/
Copy pathDebug.php
File metadata and controls
48 lines (33 loc) · 1 KB
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
<?php
namespace Dreamcoil;
class Debug
{
/**
* Adds an information to the debug console
*
* @param string $info
* @param string $level
* @throw exception
*/
public static function add($info, $level)
{
global $dreamcoil_debug;
if(is_string($info)) $dreamcoil_debug .= "\n " . $level . " " . date(DATE_RFC2822) . " : " . $info;
else throw new \Exception("The debug text must to be a string");
}
/**
* Gets the debug text
*
* @return string
*/
public static function get($html = false)
{
global $dreamcoil_debug;
if(!$html) return $dreamcoil_debug;
$dreamcoil_debug = '<pre><code>' . $dreamcoil_debug . '</code></pre>';
$dreamcoil_debug = str_replace('[info]', '<span style="color: blue">[info]</span>', $dreamcoil_debug);
$dreamcoil_debug = str_replace('[Warn]', '<span style="color: orange">[Warn]</span>', $dreamcoil_debug);
$dreamcoil_debug = str_replace('[ERROR]', '<span style="color: red">[ERROR]</span>', $dreamcoil_debug);
return $dreamcoil_debug;
}
}