fix: unify log path to runtime/log/ for all contexts

- Logger: use root_path()/runtime/log/ instead of runtime_path()/log/
  (runtime_path() returns app-specific path in multi-app mode)
- Remove debug output from Log controller
This commit is contained in:
testadmin
2026-05-14 11:44:57 +08:00
parent cbe48e938a
commit 7fe15a0d50
2 changed files with 13 additions and 17 deletions
+12 -16
View File
@@ -20,21 +20,17 @@ class Log
$raw2 = file_get_contents('php://input'); $raw2 = file_get_contents('php://input');
$data = json_decode($raw2, true) ?: []; $data = json_decode($raw2, true) ?: [];
} }
try { \app\utils\Logger::error(\app\utils\Logger::CAT_FRONTEND, $data['message'] ?? 'unknown', [
\app\utils\Logger::error(\app\utils\Logger::CAT_FRONTEND, $data['message'] ?? 'unknown', [ 'source' => $data['source'] ?? 'unknown',
'source' => $data['source'] ?? 'unknown', 'type' => $data['type'] ?? 'error',
'type' => $data['type'] ?? 'error', 'stack' => isset($data['stack']) ? substr($data['stack'], 0, 2000) : '',
'stack' => isset($data['stack']) ? substr($data['stack'], 0, 2000) : '', 'file' => $data['file'] ?? '',
'file' => $data['file'] ?? '', 'url' => $data['url'] ?? '',
'url' => $data['url'] ?? '', 'line' => $data['line'] ?? '',
'line' => $data['line'] ?? '', 'col' => $data['col'] ?? '',
'col' => $data['col'] ?? '', 'ua' => Request::instance()->header('user-agent', ''),
'ua' => Request::instance()->header('user-agent', ''), 'ip' => Request::instance()->ip(),
'ip' => Request::instance()->ip(), ]);
]); return json(['status' => 1]);
return json(['status' => 1, 'path' => runtime_path(), 'data_keys' => array_keys($data)]);
} catch (\Throwable $e) {
return json(['status' => 0, 'error' => $e->getMessage(), 'path' => runtime_path()]);
}
} }
} }
+1 -1
View File
@@ -13,7 +13,7 @@ class Logger
{ {
$date = date('Y-m-d'); $date = date('Y-m-d');
$time = date('Y-m-d H:i:s'); $time = date('Y-m-d H:i:s');
$dir = runtime_path() . 'log' . DIRECTORY_SEPARATOR . $category; $dir = root_path() . 'runtime' . DIRECTORY_SEPARATOR . 'log' . DIRECTORY_SEPARATOR . $category;
if (!is_dir($dir)) { if (!is_dir($dir)) {
mkdir($dir, 0755, true); mkdir($dir, 0755, true);
} }