PSR规范调整

This commit is contained in:
thinkphp
2015-10-04 13:05:15 +08:00
parent 1cfb3704c6
commit 27e724bb3c
135 changed files with 9426 additions and 11556 deletions

View File

@@ -11,17 +11,19 @@
namespace think\log\driver;
class File {
class File
{
protected $config = [
'time_format' => ' c ',
'file_size' => 2097152,
'path' => '',
protected $config = [
'time_format' => ' c ',
'file_size' => 2097152,
'path' => '',
];
// 实例化并传入参数
public function __construct($config=[]){
$this->config = array_merge($this->config,$config);
public function __construct($config = [])
{
$this->config = array_merge($this->config, $config);
}
/**
@@ -31,13 +33,18 @@ class File {
* @param string $destination 写入目标
* @return void
*/
public function write($log,$destination='') {
public function write($log, $destination = '')
{
$now = date($this->config['time_format']);
if(empty($destination))
$destination = $this->config['path'].date('y_m_d').'.log';
if (empty($destination)) {
$destination = $this->config['path'] . date('y_m_d') . '.log';
}
//检测日志文件大小,超过配置大小则备份日志文件重新生成
if(is_file($destination) && floor($this->config['file_size']) <= filesize($destination) )
rename($destination,dirname($destination).'/'.time().'-'.basename($destination));
error_log("[{$now}] {$_SERVER['SERVER_ADDR']} {$_SERVER['REMOTE_ADDR']} {$_SERVER['REQUEST_URI']}\r\n{$log}\r\n", 3,$destination);
if (is_file($destination) && floor($this->config['file_size']) <= filesize($destination)) {
rename($destination, dirname($destination) . '/' . time() . '-' . basename($destination));
}
error_log("[{$now}] {$_SERVER['SERVER_ADDR']} {$_SERVER['REMOTE_ADDR']} {$_SERVER['REQUEST_URI']}\r\n{$log}\r\n", 3, $destination);
}
}

View File

@@ -11,15 +11,17 @@
namespace think\log\driver;
class Sae {
class Sae
{
protected $config = [
'log_time_format' => ' c ',
protected $config = [
'log_time_format' => ' c ',
];
// 实例化并传入参数
public function __construct($config=[]){
$this->config = array_merge($this->config,$config);
public function __construct($config = [])
{
$this->config = array_merge($this->config, $config);
}
/**
@@ -29,19 +31,20 @@ class Sae {
* @param string $destination 写入目标
* @return void
*/
public function write($log,$destination='') {
static $is_debug = null;
$now = date($this->config['log_time_format']);
$logstr = "[{$now}] {$_SERVER['SERVER_ADDR']} {$_SERVER['REMOTE_ADDR']} {$_SERVER['REQUEST_URI']}\r\n{$log}\r\n";
if(is_null($is_debug)){
public function write($log, $destination = '')
{
static $is_debug = null;
$now = date($this->config['log_time_format']);
$logstr = "[{$now}] {$_SERVER['SERVER_ADDR']} {$_SERVER['REMOTE_ADDR']} {$_SERVER['REQUEST_URI']}\r\n{$log}\r\n";
if (is_null($is_debug)) {
preg_replace('@(\w+)\=([^;]*)@e', '$appSettings[\'\\1\']="\\2";', $_SERVER['HTTP_APPCOOKIE']);
$is_debug = in_array($_SERVER['HTTP_APPVERSION'], explode(',', $appSettings['debug'])) ? true : false;
}
if($is_debug){
sae_set_display_errors(false);//记录日志不将日志打印出来
if ($is_debug) {
sae_set_display_errors(false); //记录日志不将日志打印出来
}
sae_debug($logstr);
if($is_debug){
if ($is_debug) {
sae_set_display_errors(true);
}