debug: add error catching to log endpoint
This commit is contained in:
@@ -16,17 +16,25 @@ class Log
|
|||||||
$raw = Request::instance()->getContent();
|
$raw = Request::instance()->getContent();
|
||||||
$data = json_decode($raw, true) ?: [];
|
$data = json_decode($raw, true) ?: [];
|
||||||
}
|
}
|
||||||
\app\utils\Logger::error(\app\utils\Logger::CAT_FRONTEND, $data['message'] ?? 'unknown', [
|
if (empty($data)) {
|
||||||
'source' => $data['source'] ?? 'unknown',
|
$raw2 = file_get_contents('php://input');
|
||||||
'type' => $data['type'] ?? 'error',
|
$data = json_decode($raw2, true) ?: [];
|
||||||
'stack' => isset($data['stack']) ? substr($data['stack'], 0, 2000) : '',
|
}
|
||||||
'file' => $data['file'] ?? '',
|
try {
|
||||||
'url' => $data['url'] ?? '',
|
\app\utils\Logger::error(\app\utils\Logger::CAT_FRONTEND, $data['message'] ?? 'unknown', [
|
||||||
'line' => $data['line'] ?? '',
|
'source' => $data['source'] ?? 'unknown',
|
||||||
'col' => $data['col'] ?? '',
|
'type' => $data['type'] ?? 'error',
|
||||||
'ua' => Request::instance()->header('user-agent', ''),
|
'stack' => isset($data['stack']) ? substr($data['stack'], 0, 2000) : '',
|
||||||
'ip' => Request::instance()->ip(),
|
'file' => $data['file'] ?? '',
|
||||||
]);
|
'url' => $data['url'] ?? '',
|
||||||
return json(['status' => 1]);
|
'line' => $data['line'] ?? '',
|
||||||
|
'col' => $data['col'] ?? '',
|
||||||
|
'ua' => Request::instance()->header('user-agent', ''),
|
||||||
|
'ip' => Request::instance()->ip(),
|
||||||
|
]);
|
||||||
|
return json(['status' => 1]);
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
return json(['status' => 0, 'error' => $e->getMessage(), 'path' => runtime_path()]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user