lwi/thinklog

高性能日志组件 - 原生支持 PSR-3,可选 ThinkPHP 深度集成

1.0.3 2025-04-13 16:42 UTC

This package is auto-updated.

Last update: 2025-04-13 16:46:41 UTC


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}'
    ]