-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfi_Logger.php
More file actions
58 lines (52 loc) · 1.38 KB
/
Copy pathfi_Logger.php
File metadata and controls
58 lines (52 loc) · 1.38 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
49
50
51
52
53
54
55
56
57
58
<?php
class Feediron_Logger{
private static $logger = false;
const LOG_NONE = 0;
const LOG_TTRSS = 1;
const LOG_TEST = 2;
const LOG_VERBOSE = 3;
public static function get(){
if(self::$logger === false){
self::$logger = new Feediron_Logger();
}
return self::$logger;
}
private $loglevel = self::LOG_NONE;
private $testlog = array();
private $time_measure = false;
public function get_log_level(){
return $this->loglevel;
}
public function set_log_level($level){
$this->loglevel = $level;
}
public function log($level, $msg, $details=''){
if($level > $this->loglevel)
return;
if($level == self::LOG_TTRSS){
trigger_error($msg, E_USER_NOTICE);
array_push($this->testlog, "<h2>LOG:</h2><pre>".htmlentities($msg)."</pre>");
}else{
array_push($this->testlog, "<h2>$msg</h2>");
array_push($this->testlog, "<details><pre>".htmlentities($details)."</pre></details>");
}
}
public function log_json($level, $msg, $json){
if($level > $this->loglevel)
return;
$this->log($level, $msg, Feediron_Json::format($json));
}
public function log_object($level, $msg, $obj){
if($level > $this->loglevel)
return;
$this->log_json($level, $msg, json_encode($obj));
}
public function log_html($level, $msg, $html=''){
if($level > $this->loglevel)
return;
$this->log($level, $msg, $html);
}
public function get_testlog(){
return $this->testlog;
}
}