lwi / thinklog
高性能日志组件 - 原生支持 PSR-3,可选 ThinkPHP 深度集成
1.0.3
2025-04-13 16:42 UTC
Requires
- php: ^7.1 || ^8.0
README
日志记录
config/log 下日志记录
public function index()
{
try {
// 业务逻辑
$user = $this->validateLogin();
return json(['user' => $user]);
} catch (\Exception $e) {
return $this->handleApiError($e);
}
}
private function validateLogin()
{
// 模拟验证失败
throw new \Exception('密码错误');
}
'json' => [
'type' => 'file',
'path' => runtime_path('logs/json'),
'json' => true, // 自动转为JSON格式
'format' => '[{timestamp}] {message} {context}'
]