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