- Create handle/controller/Log.php (no auth) for dealer error reports - Update error-report.js URL: /index/log_report → /log/report - index app already has Log controller at /log/report
29 lines
949 B
PHP
29 lines
949 B
PHP
<?php
|
|
declare (strict_types = 1);
|
|
|
|
namespace app\handle\controller;
|
|
|
|
use think\facade\Request;
|
|
use think\response\Json;
|
|
|
|
class Log
|
|
{
|
|
public function report(): Json
|
|
{
|
|
if (!Request::instance()->isPost()) return json(['status' => 0]);
|
|
$data = Request::instance()->post();
|
|
\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]);
|
|
}
|
|
}
|