Browse Source

Fix

remastering
GamerClassN7 1 year ago
parent
commit
f80b9a6b43
1 changed files with 7 additions and 1 deletions
  1. +7
    -1
      app/models/managers/LogManager.php

+ 7
- 1
app/models/managers/LogManager.php View File

@ -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…
Cancel
Save