Fix
This commit is contained in:
parent
49f2354908
commit
f80b9a6b43
@ -8,6 +8,7 @@
|
||||
class LogManager
|
||||
{
|
||||
private $logFile;
|
||||
private $filePath = null;
|
||||
private $logLevel = 1;
|
||||
|
||||
public function __construct($fileName = "")
|
||||
@ -15,12 +16,13 @@ class LogManager
|
||||
if ($fileName == ""){
|
||||
$fileName = '../logs/'. date("Y-m-d").'.log';
|
||||
}
|
||||
|
||||
if(!is_dir("../logs/"))
|
||||
{
|
||||
mkdir("../logs/");
|
||||
}
|
||||
|
||||
$this->logFile = fopen($fileName, "a") or die("Unable to open file!");
|
||||
$this->filePath = $fileName;
|
||||
}
|
||||
|
||||
public function setLevel($type = LogRecordTypess::WARNING){
|
||||
@ -28,6 +30,10 @@ class LogManager
|
||||
}
|
||||
|
||||
public function write($value, $type = LogRecordTypess::ERROR){
|
||||
if ($this->logFile == null) {
|
||||
$this->logFile = fopen($this->filePath, "a") or die("Unable to open file!");
|
||||
}
|
||||
|
||||
if ($type['level'] <= $this->logLevel) {
|
||||
$record = "[".date("H:m:s")."][".$type['identifier']."]" . $value . "\n";
|
||||
fwrite($this->logFile, $record);
|
||||
|
Loading…
Reference in New Issue
Block a user