-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLogger.php
More file actions
83 lines (46 loc) · 1.31 KB
/
Logger.php
File metadata and controls
83 lines (46 loc) · 1.31 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
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
<?php
namespace Twist;
class Logger {
public $timeFormat = 'm-d-y H:i:s';
public $seperator = ' | ';
public $eol = "\r\n";
public $indent = " ";
public $path;
public function __construct($message = null)
{
error_reporting(0);
$this->path = PLUGIN_DIR;
if($message != null){
$this->log($message);
}
}
public function write($m)
{
if (isset($this->path)) {
try {
$fh = null;
$logfile = $this->path . "Debug.log";
$fh = (file_exists($logfile)) ? fopen($logfile, "a+") : fopen($logfile, "w+");
fwrite($fh, $this->eol);
fwrite($fh, $this->getTime());
fwrite($fh, $this->seperator);
fwrite($fh, $m);
fclose($fh);
} catch (\Exception $e) {
$this->log($e->getMessage());
}
} else {
error_log('Log.php - Error activating plugin!!!', 0);
}
}
public function log($message)
{
$this->write($message);
}
public function getTime() {
return date($this->timeFormat);
}
function __destruct()
{
}
}