{"id":19518789,"url":"https://github.com/ssi-anik/loguzz","last_synced_at":"2025-04-26T07:30:55.973Z","repository":{"id":40652232,"uuid":"249184972","full_name":"ssi-anik/loguzz","owner":"ssi-anik","description":"Loguzz is a logger for guzzle request and response","archived":false,"fork":false,"pushed_at":"2024-08-28T00:06:37.000Z","size":106,"stargazers_count":16,"open_issues_count":0,"forks_count":6,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-17T15:49:53.167Z","etag":null,"topics":["guzzlehttp","laravel","logging","lumen","requests","responses"],"latest_commit_sha":null,"homepage":"https://bit.ly/3dwgYB1","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ssi-anik.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-03-22T13:05:19.000Z","updated_at":"2025-04-09T10:15:37.000Z","dependencies_parsed_at":"2024-06-19T01:26:04.253Z","dependency_job_id":"e7444c49-2e85-46af-848c-95eb2f86376b","html_url":"https://github.com/ssi-anik/loguzz","commit_stats":{"total_commits":76,"total_committers":3,"mean_commits":"25.333333333333332","dds":0.03947368421052633,"last_synced_commit":"2202ece6b00949018ccc794b9249cee0c764adfc"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ssi-anik%2Floguzz","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ssi-anik%2Floguzz/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ssi-anik%2Floguzz/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ssi-anik%2Floguzz/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ssi-anik","download_url":"https://codeload.github.com/ssi-anik/loguzz/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250953235,"owners_count":21513278,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["guzzlehttp","laravel","logging","lumen","requests","responses"],"created_at":"2024-11-11T00:14:31.242Z","updated_at":"2025-04-26T07:30:55.719Z","avatar_url":"https://github.com/ssi-anik.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Loguzz\n[![codecov](https://codecov.io/gh/ssi-anik/loguzz/branch/master/graph/badge.svg?token=L35HVDZ91V)](https://codecov.io/gh/ssi-anik/loguzz)\n[![Total Downloads](https://poser.pugx.org/anik/loguzz/downloads)](//packagist.org/packages/anik/loguzz)\n[![Latest Stable Version](https://poser.pugx.org/anik/loguzz/v)](//packagist.org/packages/anik/loguzz)\n==============\n\nLoguzz is a middleware for [Guzzle](https://github.com/guzzle/guzzle) which logs requests and responses.\n\n## Installation\n\nYou'll need composer to install the package.\n`composer require anik/loguzz`\n\n## Documentation V1\n\nFind the thorough [documentation here](https://bit.ly/3dwgYB1).\n\n## Documentation V4/V3/V2\n\nTo log a request, you'll need to push `Loguzz\\Middleware\\LogMiddleware` to Guzzle's handler.\n\n```php\n$logger = new \\ColinODell\\PsrTestLogger\\TestLogger();\n$handlerStack = \\GuzzleHttp\\HandlerStack::create();\n$options = [];\n$handlerStack-\u003epush(new \\Loguzz\\Middleware\\LogMiddleware($logger, $options), 'logger');\n```\n\n- `$logger` is the implementation of `Psr\\Log\\LoggerInterface`.\n- `$options` is an array to change the default behaviour of LogMiddleware.\n- `'logger'` is the internal name of the middleware for Guzzle. It can be any name.\n\n### Options\n\n```php\n// Default values\n$options = [\n    'length' =\u003e 100,\n    'log_request' =\u003e true,\n    'log_response' =\u003e true,\n    'success_only' =\u003e false,\n    'exceptions_only' =\u003e false,\n    'log_level' =\u003e 'debug',\n    'request_formatter' =\u003e new \\Loguzz\\Formatter\\RequestCurlFormatter(),\n    'response_formatter' =\u003e new \\Loguzz\\Formatter\\ResponseJsonFormatter(),\n    'exception_formatter' =\u003e new \\Loguzz\\Formatter\\ExceptionJsonFormatter(),\n    'tag' =\u003e '',\n    'force_json' =\u003e true,\n    'separate' =\u003e false,\n];\n```\n\n- `length` - **int**. Minimum 10. To set the length of when formatting request\n  with `\\Loguzz\\Formatter\\RequestCurlFormatter`.\n- `log_request` - **bool**. To enable or disable request logging.\n- `log_response` - **bool**. To enable or disable response logging.\n- `success_only` - **bool**. Only log successful responses. **If the server could be reached, it's a success.**\n- `exception_only` - **bool** Only log exceptions. **Logs when an exception is thrown by Guzzle for connection/timeout\n  related exceptions**.\n- `log_level` - **string**. Any valid log level.\n- `request_formatter` - instance of **\\Loguzz\\Formatter\\AbstractRequestFormatter**. Available\n    * `\\Loguzz\\Formatter\\RequestArrayFormatter`\n    * `\\Loguzz\\Formatter\\RequestCurlFormatter`\n    * `\\Loguzz\\Formatter\\RequestJsonFormatter`\n- `response_formatter` - instance of **\\Loguzz\\Formatter\\AbstractResponseFormatter**\n    * `\\Loguzz\\Formatter\\ResponseArrayFormatter`\n    * `\\Loguzz\\Formatter\\ResponseJsonFormatter`\n- `exception_formatter` - instance of **\\Loguzz\\Formatter\\AbstractResponseFormatter**\n    * `\\Loguzz\\Formatter\\ExceptionArrayFormatter`\n    * `\\Loguzz\\Formatter\\ExceptionJsonFormatter`\n- `tag` - **string**. **Empty** by default. When non-empty string, it'll log the formatted data under this tag. Tag can\n  be used to search for specific type of request/response in your log file or your storage.\n- `force_json` - **bool**. **true** by default. It is only applicable when **tag** is non-empty string. If enabled, it\n  will then log data as\n  json string, otherwise it'll log as an array. **If set to** `false`, **the code may break due to the type-hint in\n  psr/log interface. If\n  your [logger interface supports array](https://github.com/laravel/framework/blob/dd5c5178274e64d0384dc30bf2c8139b00dba098/src/Illuminate/Log/Logger.php#L260),\n  it will work.**\n- `separate` - **bool**. It is only applicable when **tag** is non-empty string. If enabled, it will then log data\n  in `{tag}.request`, `{tag}.success`, `{tag}.failure` for request logging, successful response and error response.\n\n### Request Formatter\n\nTo create a new request formatter you need to **extend** the `\\Loguzz\\Formatter\\AbstractRequestFormatter` class.\n\n### Response Formatter\n\nTo create a new response formatter you need to **extend** the `\\Loguzz\\Formatter\\AbstractResponseFormatter` class.\n\n### Exception Formatter\n\nTo create a new exception formatter you need to **extend** the `\\Loguzz\\Formatter\\AbstractExceptionFormatter` class.\n\n## Manual Request formatting\n\nImplementations of `\\Loguzz\\Formatter\\AbstractRequestFormatter::format` accept parameters as\n\n- `\\Psr\\Http\\Message\\RequestInterface $request`\n- `array $options = []`\n\nAvailable request formatters parse data from `$request` and **cookies** from the `$options`. The values\nin `$options['cookies']` must be an implementation of `\\GuzzleHttp\\Cookie\\CookieJarInterface`. To parse **cookies**, the\nrequest URL must contain the **domain**.\n\n## Manual Response formatting\n\nImplementations of `\\Loguzz\\Formatter\\AbstractResponseFormatter::format` accept parameters as\n\n- `\\Psr\\Http\\Message\\RequestInterface $request`\n- `\\Psr\\Http\\Message\\ResponseInterface $response`\n- `array $options = []`\n\nAvailable response formatters parse data from `$response` and **cookies** from the `set-cookie` header. To parse\n**cookies**, the request URL must contain the **domain**.\n\nThe `set-cookie` headers will not be available in the headers for available response formatters.\n\n## Issues \u0026 PRs\n\nIf you think something is missing in the package or cause bug, please report an Issue. If you're available and want to\ncontribute to the repository, please submit a PR.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fssi-anik%2Floguzz","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fssi-anik%2Floguzz","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fssi-anik%2Floguzz/lists"}