From 7c3a9d874213cc1dbb7b7d28f1881f9311ffe581 Mon Sep 17 00:00:00 2001 From: zhaoxiang <756958008@qq.com> Date: Sun, 14 Jan 2018 01:54:13 +0800 Subject: [PATCH] =?UTF-8?q?fixed=20=E4=BC=98=E5=8C=96ApiLog=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=A4=B9=E4=B8=8D=E5=AD=98=E5=9C=A8=E7=9A=84=E6=8A=A5?= =?UTF-8?q?=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/util/ApiLog.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/application/util/ApiLog.php b/application/util/ApiLog.php index 2ab52f5..fd2d33c 100644 --- a/application/util/ApiLog.php +++ b/application/util/ApiLog.php @@ -84,7 +84,7 @@ class ApiLog { self::$userInfo )); if (!file_exists($logPath)) { - mkdir($logPath); + mkdir($logPath, 0755, true); } @file_put_contents($logPath . date('YmdH') . '.log', $logStr . "\n", FILE_APPEND); } @@ -95,7 +95,10 @@ class ApiLog { * @param string $type 日志文件名称 * @param string $filePath */ - public static function writeLog($log, $type = 'sql', $filePath = '.' . DS . 'runtime' . DS) { + public static function writeLog($log, $type = 'sql', $filePath = '') { + if(!$filePath) { + $filePath = '.' . DS . 'runtime' . DS; + } $filename = $filePath . date("Ymd") . '_' . $type . ".log"; @$handle = fopen($filename, "a+"); @fwrite($handle, date('Y-m-d H:i:s') . "\t" . $log . "\r\n");