vendor文件夹 缺失文件提交
This commit is contained in:
44
vendor/Alidayu/TopLogger.php
vendored
Normal file
44
vendor/Alidayu/TopLogger.php
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
class TopLogger
|
||||
{
|
||||
public $conf = array(
|
||||
"separator" => "\t",
|
||||
"log_file" => ""
|
||||
);
|
||||
|
||||
private $fileHandle;
|
||||
|
||||
protected function getFileHandle()
|
||||
{
|
||||
if (null === $this->fileHandle)
|
||||
{
|
||||
if (empty($this->conf["log_file"]))
|
||||
{
|
||||
trigger_error("no log file spcified.");
|
||||
}
|
||||
$logDir = dirname($this->conf["log_file"]);
|
||||
if (!is_dir($logDir))
|
||||
{
|
||||
mkdir($logDir, 0777, true);
|
||||
}
|
||||
$this->fileHandle = fopen($this->conf["log_file"], "a");
|
||||
}
|
||||
return $this->fileHandle;
|
||||
}
|
||||
|
||||
public function log($logData)
|
||||
{
|
||||
return false;//屏蔽log, 错误log已经保存到数据库中
|
||||
if ("" == $logData || array() == $logData)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (is_array($logData))
|
||||
{
|
||||
$logData = implode($this->conf["separator"], $logData);
|
||||
}
|
||||
$logData = $logData. "\n";
|
||||
fwrite($this->getFileHandle(), $logData);
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user