Simple Error Class
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 | class Error {
private $error;
private $name;
public function Error($name = null) {
if (!empty($name)) {
$this->name = $name;
} else {
$this->name = "log";
};
}
public function _add($error, $id = null) {
$time = "[" . date("Y-m-d H:i:s") . "]";
$this->error = $time . " (" . $id . ") " . $error;
$this->_store();
}
private function _store() {
$file = fopen($this->name.".txt", "a+");
fwrite($file, $this->error."\n");
fclose($file);
$this->error = null;
}
}
|