PHPでログを書き込む、上限サイズを超えるとき自動的ファイルを作成

PHPコード:
function write($message,$level=’ERROR’,$type=3,$destination=",$extra=") {
$LOG_PATH = './’;
$LOG_FILE_SIZE = 100;
$now = date('[ c ]’);
$type = $type?$type:3;
if($type == 3) { // ファイル形式でログを書き込む
if(empty($destination))
$destination = $LOG_PATH.date('y-m-d’).’.log’;
//ログファイルサイズを検証、上限を超えるときファイルを再生成
if(is_file($destination) && floor($LOG_FILE_SIZE) <= filesize($destination) )
rename($destination,dirname($destination).’/’.basename($destination).’-'.time().’.log’);
}
error_log(“{$now} {$level}: {$message}\r\n", $type,$destination,$extra );
//clearstatcache();
}
write('test_startnews24’);

PHP

Posted by arkgame