Merge branch 'master' of http://47.244.231.31:8099/zhl/globalso-v6
正在显示
1 个修改的文件
包含
14 行增加
和
0 行删除
| @@ -32,8 +32,22 @@ class LogFormatterFactory | @@ -32,8 +32,22 @@ class LogFormatterFactory | ||
| 32 | $path = date('Y-m', $time) . '/' . date('d', $time) . '_' . $suffix . '.log'; | 32 | $path = date('Y-m', $time) . '/' . date('d', $time) . '_' . $suffix . '.log'; |
| 33 | $path = 'logs/' . $config['prefix'] . '/' . $path; | 33 | $path = 'logs/' . $config['prefix'] . '/' . $path; |
| 34 | $path = storage_path($path); | 34 | $path = storage_path($path); |
| 35 | + | ||
| 36 | + try { | ||
| 37 | + if (!file_exists($path)) { | ||
| 38 | + $directory = pathinfo($path, PATHINFO_DIRNAME); | ||
| 39 | + if(!file_exists($directory)){ | ||
| 40 | + mkdir($directory, 0644, true); | ||
| 41 | + chown($directory, 'www'); | ||
| 42 | + } | ||
| 43 | + touch($path); | ||
| 44 | + chown($path, 'www'); | ||
| 45 | + } | ||
| 46 | + }catch (\Throwable $exception){} | ||
| 47 | + | ||
| 35 | $handler = new StreamHandler($path, $level, false); | 48 | $handler = new StreamHandler($path, $level, false); |
| 36 | $handler->setFormatter(new LineFormatter(null, 'Y-m-d H:i:s', false, true)); | 49 | $handler->setFormatter(new LineFormatter(null, 'Y-m-d H:i:s', false, true)); |
| 50 | + | ||
| 37 | return $handler; | 51 | return $handler; |
| 38 | } | 52 | } |
| 39 | 53 |
-
请 注册 或 登录 后发表评论