-
Notifications
You must be signed in to change notification settings - Fork 0
/
Cichrome.php
84 lines (67 loc) · 1.58 KB
/
Cichrome.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
if (!defined('BASEPATH')) exit('No direct script access allowed');
require_once 'chromelog/ChromePhp.php';
class Cichrome
{
public function __construct()
{
$this->ci = & get_instance();
$this->log_threshold = $this->ci->config->item('log_threshold');
}
public function log($level, $message)
{
$log = $this->get_log_level($level);
if($log <= $this->log_threshold)
{
if($level === 'debug')
{
$level = 'log';
}
ChromePhp::{$level}($message);
}
}
public function warn($message)
{
return $this->log('warn', $message);
}
public function debug($message)
{
return $this->log('debug', $message);
}
public function error($message)
{
return $this->log('error', $message);
}
public function info($message)
{
return $this->log('info', $message);
}
public function group($name=NULL)
{
ChromePhp::group($name);
}
public function groupCollapsed($name=NULL)
{
ChromePhp::groupCollapsed($name);
}
public function groupEnd($name=NULL)
{
ChromePhp::groupEnd($name);
}
private function get_log_level($level)
{
$levels = array(
'error' => 1,
'debug' => 2,
'info' => 3,
'warn' => 3,
'all' => 4,
'log' => 4
);
if(!$level || !array_key_exists($level, $levels))
{
return 0;
}
return $levels[$level];
}
}