mirror of
https://github.com/codeigniter4/CodeIgniter4.git
synced 2025-02-20 11:44:28 +08:00
Merge pull request #8108 from kenjis/feat-route-logging-in-exception
feat: add Method/Route logging in exceptionHandler()
This commit is contained in:
commit
a4127ca3d4
@ -125,16 +125,21 @@ class Exceptions
|
||||
|
||||
[$statusCode, $exitCode] = $this->determineCodes($exception);
|
||||
|
||||
$this->request = Services::request();
|
||||
|
||||
if ($this->config->log === true && ! in_array($statusCode, $this->config->ignoreCodes, true)) {
|
||||
log_message('critical', "{message}\nin {exFile} on line {exLine}.\n{trace}", [
|
||||
'message' => $exception->getMessage(),
|
||||
'exFile' => clean_path($exception->getFile()), // {file} refers to THIS file
|
||||
'exLine' => $exception->getLine(), // {line} refers to THIS line
|
||||
'trace' => self::renderBacktrace($exception->getTrace()),
|
||||
$uri = $this->request->getPath() === '' ? '/' : $this->request->getPath();
|
||||
$routeInfo = '[Method: ' . strtoupper($this->request->getMethod()) . ', Route: ' . $uri . ']';
|
||||
|
||||
log_message('critical', "{message}\n{routeInfo}\nin {exFile} on line {exLine}.\n{trace}", [
|
||||
'message' => $exception->getMessage(),
|
||||
'routeInfo' => $routeInfo,
|
||||
'exFile' => clean_path($exception->getFile()), // {file} refers to THIS file
|
||||
'exLine' => $exception->getLine(), // {line} refers to THIS line
|
||||
'trace' => self::renderBacktrace($exception->getTrace()),
|
||||
]);
|
||||
}
|
||||
|
||||
$this->request = Services::request();
|
||||
$this->response = Services::response();
|
||||
|
||||
// Get the first exception.
|
||||
|
Loading…
x
Reference in New Issue
Block a user