mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-07-09 03:22:51 +08:00
优化数据库的调试日志;
This commit is contained in:
@@ -75,35 +75,55 @@ class DebugMysql implements LogHandlerInterface
|
|||||||
|
|
||||||
$app_name = app('http')->getName() ?: '';
|
$app_name = app('http')->getName() ?: '';
|
||||||
|
|
||||||
$controller_name = request()->controller();
|
$controller_name = '';
|
||||||
$action_name = request()->action();
|
$action_name = '';
|
||||||
|
|
||||||
if (App::runningInConsole()) {
|
if (App::runningInConsole()) {
|
||||||
$app_name = 'cli';
|
$app_name = 'cli';
|
||||||
|
} else {
|
||||||
|
|
||||||
|
$controller_name = request()->controller();
|
||||||
|
$action_name = request()->action();
|
||||||
}
|
}
|
||||||
|
|
||||||
$create_time = time();
|
$create_time = time();
|
||||||
|
|
||||||
|
|
||||||
$create_time_title = date('Y-m-d H:i:s', $create_time);
|
$create_time_title = date('Y-m-d H:i:s', $create_time);
|
||||||
|
|
||||||
$log_key = uniqid();
|
$log_key = '';
|
||||||
|
|
||||||
|
if (defined('REUQEST_UID')) {
|
||||||
|
$log_key = REUQEST_UID;
|
||||||
|
} else {
|
||||||
|
$log_key = uniqid();
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($log as $log_level => $log_list) {
|
foreach ($log as $log_level => $log_list) {
|
||||||
foreach ($log_list as $key => $log_item) {
|
foreach ($log_list as $key => $log_item) {
|
||||||
|
|
||||||
if (!is_string($log_item)) {
|
$log_content = $log_item;
|
||||||
$log_item = json_encode($log_item, JSON_UNESCAPED_UNICODE);
|
|
||||||
|
if ($log_item instanceof \Throwable) {
|
||||||
|
|
||||||
|
$log_content = [];
|
||||||
|
|
||||||
|
$log_content['message'] = $log_item->getMessage();
|
||||||
|
$log_content['line'] = $log_item->getLine();
|
||||||
|
$log_content['file'] = $log_item->getFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!is_string($log_content)) {
|
||||||
|
$log_content = json_encode($log_content, JSON_UNESCAPED_UNICODE);
|
||||||
}
|
}
|
||||||
$log_data = [
|
$log_data = [
|
||||||
'level' => $log_level,
|
'level' => $log_level,
|
||||||
'content' => $log_item,
|
'content' => $log_content,
|
||||||
'create_time' => $create_time,
|
'create_time' => $create_time,
|
||||||
'create_time_title' => $create_time_title,
|
'create_time_title' => $create_time_title,
|
||||||
'uid' => $log_key,
|
'uid' => $log_key,
|
||||||
'app_name' => $app_name,
|
'app_name' => $app_name,
|
||||||
'controller_name' => $controller_name,
|
'controller_name' => $controller_name,
|
||||||
'action_name' => $action_name,
|
'action_name' => $action_name
|
||||||
];
|
];
|
||||||
|
|
||||||
if (!is_null($this->pdo)) {
|
if (!is_null($this->pdo)) {
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ require __DIR__ . '/../vendor/autoload.php';
|
|||||||
// 声明全局变量
|
// 声明全局变量
|
||||||
define('DS', DIRECTORY_SEPARATOR);
|
define('DS', DIRECTORY_SEPARATOR);
|
||||||
define('ROOT_PATH', __DIR__ . DS . '..' . DS);
|
define('ROOT_PATH', __DIR__ . DS . '..' . DS);
|
||||||
|
define('REUQEST_UID', uniqid());
|
||||||
// 执行HTTP应用并响应
|
// 执行HTTP应用并响应
|
||||||
$http = (new App())->http;
|
$http = (new App())->http;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user