debug: add error catching to log endpoint
This commit is contained in:
@@ -16,6 +16,11 @@ class Log
|
||||
$raw = Request::instance()->getContent();
|
||||
$data = json_decode($raw, true) ?: [];
|
||||
}
|
||||
if (empty($data)) {
|
||||
$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',
|
||||
@@ -28,5 +33,8 @@ class Log
|
||||
'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