-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathlogger.class.php
More file actions
46 lines (34 loc) · 890 Bytes
/
logger.class.php
File metadata and controls
46 lines (34 loc) · 890 Bytes
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
<?php
/*
Logger v1.0
(c) 2017 by Thielicious
Logger is a simple class that lets you record actions in a text file.
*/
class Logger {
private
$file,
$timestamp;
public function __construct(string $filename) {
$this->file = $filename;
}
public function setTimestamp(string $format) {
$this->timestamp = "<strong>".date($format)." » </strong>";
}
public function putLog(string $insert) {
if (isset($this->timestamp)) {
file_put_contents($this->file, $this->timestamp.$insert."<br>", FILE_APPEND);
} else {
trigger_error("Timestamp not set", E_USER_ERROR);
}
}
public function getLog() {
if (isset($this->file)) {
$content = @file_get_contents($this->file);
return $content;
}
}
public function clear() {
@unlink($this->file);
}
}
?>