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:
@@ -20,21 +20,17 @@ class Log
|
||||
$raw2 = file_get_contents('php://input');
|
||||
$data = json_decode($raw2, true) ?: [];
|
||||
}
|
||||
try {
|
||||
\app\utils\Logger::error(\app\utils\Logger::CAT_FRONTEND, $data['message'] ?? 'unknown', [
|
||||
'source' => $data['source'] ?? 'unknown',
|
||||
'type' => $data['type'] ?? 'error',
|
||||
'stack' => isset($data['stack']) ? substr($data['stack'], 0, 2000) : '',
|
||||
'file' => $data['file'] ?? '',
|
||||
'url' => $data['url'] ?? '',
|
||||
'line' => $data['line'] ?? '',
|
||||
'col' => $data['col'] ?? '',
|
||||
'ua' => Request::instance()->header('user-agent', ''),
|
||||
'ip' => Request::instance()->ip(),
|
||||
]);
|
||||
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()]);
|
||||
}
|
||||
\app\utils\Logger::error(\app\utils\Logger::CAT_FRONTEND, $data['message'] ?? 'unknown', [
|
||||
'source' => $data['source'] ?? 'unknown',
|
||||
'type' => $data['type'] ?? 'error',
|
||||
'stack' => isset($data['stack']) ? substr($data['stack'], 0, 2000) : '',
|
||||
'file' => $data['file'] ?? '',
|
||||
'url' => $data['url'] ?? '',
|
||||
'line' => $data['line'] ?? '',
|
||||
'col' => $data['col'] ?? '',
|
||||
'ua' => Request::instance()->header('user-agent', ''),
|
||||
'ip' => Request::instance()->ip(),
|
||||
]);
|
||||
return json(['status' => 1]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ class Logger
|
||||
{
|
||||
$date = date('Y-m-d');
|
||||
$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)) {
|
||||
mkdir($dir, 0755, true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user