Commit 7ef2101c authored by 刘小敏's avatar 刘小敏

试戴日志优化

parent 6728fa02
......@@ -42,11 +42,11 @@ class LogDb extends Model
$model = new self();
$insertData = [
'user_id' => $data['user_id'] ?? 0,
'user_name' => $data['user_name'] ?? '',
// 'user_name' => $data['user_name'] ?? '',
'log_type' => $data['log_type'] ?? 'info',
'log_category' => $data['log_category'] ?? 'system',
'log_content' => $data['log_content'] ?? '',
'ip' => $data['ip'] ?? request()->ip(),
// 'ip' => $data['ip'] ?? request()->ip(),
'created_at' => date('Y-m-d H:i:s'),
];
......
......@@ -21,15 +21,15 @@ class TestLogDb extends Command
// 测试1:写入测试日志
$output->writeln('测试1:写入测试日志');
custom_log('这是一条测试日志', 'test', 'info');
custom_log('这是一条测试日志', 888, 'test', 'info');
$output->writeln('✓ 日志写入成功');
$output->writeln('');
// 测试2:写入不同级别的日志
$output->writeln('测试2:写入不同级别的日志');
custom_log('这是一条错误日志', 'test', 'error');
custom_log('这是一条调试日志', 'test', 'debug');
custom_log('这是一条警告日志', 'test', 'warning');
custom_log('这是一条错误日志', 888, 'test', 'error');
custom_log('这是一条调试日志', 888, 'test', 'debug');
custom_log('这是一条警告日志', 888, 'test', 'warning');
$output->writeln('✓ 不同级别日志写入成功');
$output->writeln('');
......
......@@ -527,7 +527,7 @@ if (!function_exists('custom_log')) {
\think\Log::record($content, $level);
// 同时记录到数据库日志表
custom_log_db($content, $name, $level);
custom_log_db($content, $user_id, $name, $level);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment