作者:zht1120 | 来源:互联网 | 2018-03-20 20:57
php代码:
self::$MAX_LOOP_COUNT) {
$result = 0;
} else {
$loop++;
$fp = self::$fileHandlerCache["$filePath"];
if (empty($fp)) {
$fp = fopen($filePath, "a+");
self::$fileHandlerCache[$filePath] = $fp;
}
if (flock($fp, LOCK_EX)) {
$result = fwrite($fp, $msg);
flock($fp, LOCK_UN);
} else {
$result = self::internalOut($filePath, $msg, $loop);
}
}
return $result;
}
function shutdown_func() {
if (!empty(LogFileUtil::$fileHandlerCache)) {
if (is_array(LogFileUtil::$fileHandlerCache)) {
foreach (LogFileUtil::$fileHandlerCache as $k => $v) {
if (is_resource($v))
//file_put_contents("close.txt",$k);
fclose($v);
}
}
}
}
}