健康最重要/**
* [payLog ⽀付⽇志log]
* @param [type] $mark [备注]
* @param [type] $log_content [内容]
* @param string $keyp [名]
* @return [type] [description]
*/
public static function mylog($mark, $log_content, $keyp = "") {
$max_size = 30000000;
if ($keyp == "") {
$log_filename = RUNTIME_PATH . '/tlogs/' . date('Ym-d') . ".log";
} else {
$log_filename = RUNTIME_PATH . '/tlogs/' . $keyp . ".log";
}
if (file_exists($log_filename) && (abs(filesize($log_filename)) > $max_size)) {
七大魔王rename($log_filename, dirname($log_filename) . DS . date('Ym-d-His') . $keyp . ".log");
}
什么盆栽$t = microtime(true);
$micro = sprintf("%06d", ($t - floor($t)) * 1000000);
$d = new \DateTime (date('Y-m-d H:i:s.' . $micro, $t));
if(is_array($log_content)){
$log_content = JSONReturn($log_content);
}
file_put_contents($log_filename, ' ' . $d->format('Y-m-d H:i:s u') . " key:" . $mark . "\r\n" . $log_content . "\r\n------------------------ --------------------------\r\n", FILE_APPEND); }
2:再在common.php中添加
/**
* ⽣成JSON数据返回值
*/
沙罗沙function JSONReturn($result)
{
return json_encode($result,JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES);
}
3:使⽤如下:Log::mylog('标题:' , '内容' , 'test.log');
发布评论