Home > php教程 > php手册 > SVN之后不提交Runtime目录 造成日志不记录

SVN之后不提交Runtime目录 造成日志不记录

WBOY
Release: 2016-06-07 11:41:25
Original
1137 people have browsed it

使用svn后 不想提交 runtime里的大量缓存和日志 所以把这个目录忽略了,却造成换了环境后目录不全导致,日志无法自动写入,修改了log的日志存储器
还是治标不治本 望能改进 Build::checkDir 附上治标不治本的代码

// +----------------------------------------------------------------------
// | TOPThink [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2011 http://topthink.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st
// +----------------------------------------------------------------------

namespace Think\Log\Driver;

class File {

protected $config = array(
'log_time_format' => ' c ',
'log_file_size' => 2097152,
'log_path' => '',
);

// 实例化并传入参数
public function __construct($config=array()){
$this->config = array_merge($this->config,$config);
}

/**
* 日志写入接口
* @access public
* @param string $log 日志信息
* @param string $destination 写入目标
* @return void
*/
public function write($log,$destination='') {
$now = date($this->config['log_time_format']);
if(empty($destination))
{
$destination = $this->config['log_path'].date('y_m_d').'.log';
}
else
{
$pathinfo = pathinfo($destination);
$this->config['log_path'] = $pathinfo['dirname'];
}
if(!is_dir($this->config['log_path'])) {
mkdir($this->config['log_path'],0755,true);
defined('DIR_SECURE_FILENAME') or define('DIR_SECURE_FILENAME', 'index.html');
defined('DIR_SECURE_CONTENT') or define('DIR_SECURE_CONTENT', ' ');
$content = DIR_SECURE_CONTENT;
$files = explode(',', DIR_SECURE_FILENAME);
foreach($files as $filename)
{
file_put_contents($this->config['log_path'].'/'.$filename,$content);
}
}
//检测日志文件大小,超过配置大小则备份日志文件重新生成
if(is_file($destination) && floor($this->config['log_file_size']) rename($destination,dirname($destination).'/'.time().'-'.basename($destination));
error_log("[{$now}] ".$_SERVER['REMOTE_ADDR'].' '.$_SERVER['REQUEST_URI']."\r\n{$log}\r\n", 3,$destination);
}
}

AD:真正免费,域名+虚机+企业邮箱=0元

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template