{"id":23359787,"url":"https://github.com/firehed/doctrine-dbal-logging-middleware","last_synced_at":"2025-04-10T10:32:05.402Z","repository":{"id":132080531,"uuid":"532136715","full_name":"Firehed/doctrine-dbal-logging-middleware","owner":"Firehed","description":"A replacement for Doctrine's SQLLogger","archived":false,"fork":false,"pushed_at":"2024-11-15T00:33:41.000Z","size":34,"stargazers_count":5,"open_issues_count":3,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-08T16:46:14.212Z","etag":null,"topics":["dbal","doctrine","logger","orm","php","psr-3"],"latest_commit_sha":null,"homepage":"","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/Firehed.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":"2022-09-03T02:44:12.000Z","updated_at":"2025-03-05T12:45:58.000Z","dependencies_parsed_at":null,"dependency_job_id":"66a082d2-dbad-486b-8de0-e8fbc26d3e29","html_url":"https://github.com/Firehed/doctrine-dbal-logging-middleware","commit_stats":{"total_commits":20,"total_committers":2,"mean_commits":10.0,"dds":"0.050000000000000044","last_synced_commit":"256d7a6fd937b43ccfc3ccd9a6734b9d43416a5a"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":"Firehed/php-library-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Firehed%2Fdoctrine-dbal-logging-middleware","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Firehed%2Fdoctrine-dbal-logging-middleware/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Firehed%2Fdoctrine-dbal-logging-middleware/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Firehed%2Fdoctrine-dbal-logging-middleware/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Firehed","download_url":"https://codeload.github.com/Firehed/doctrine-dbal-logging-middleware/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248199136,"owners_count":21063641,"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":["dbal","doctrine","logger","orm","php","psr-3"],"created_at":"2024-12-21T11:11:58.059Z","updated_at":"2025-04-10T10:32:05.395Z","avatar_url":"https://github.com/Firehed.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DBAL Logger\nA replacement for the the former Doctrine DBAL SQLLogger\n\n[![Test](https://github.com/Firehed/doctrine-dbal-logging-middleware/actions/workflows/test.yml/badge.svg)](https://github.com/Firehed/doctrine-dbal-logging-middleware/actions/workflows/test.yml)\n[![Lint](https://github.com/Firehed/doctrine-dbal-logging-middleware/actions/workflows/lint.yml/badge.svg)](https://github.com/Firehed/doctrine-dbal-logging-middleware/actions/workflows/lint.yml)\n[![Static analysis](https://github.com/Firehed/doctrine-dbal-logging-middleware/actions/workflows/static-analysis.yml/badge.svg)](https://github.com/Firehed/doctrine-dbal-logging-middleware/actions/workflows/static-analysis.yml)\n[![codecov](https://codecov.io/gh/Firehed/doctrine-dbal-logging-middleware/branch/main/graph/badge.svg?token=rcevTlCKj3)](https://codecov.io/gh/Firehed/doctrine-dbal-logging-middleware)\n\n## Why?\nDoctrine\\DBAL\\Logging\\SQLLogger was deprecated.\nThe bundled Middleware-based replacement is _similar_, but with a few critical differences:\n\n- It's tied directly to a PSR-3 logger\n- The log format (and levels) is part of the middleware; it cannot be customized\n- There is no event for queries completing; this makes it impossible to use the logger for application telemetry.\n\n## How this is similar to the original\n\nThe basic `QueryLogger` API remains the same: `startQuery()` and `stopQuery()`.\n\n## How this is different from the original\n\n`Doctrine\\DBAL\\Logging\\SQLLogger` is now `Firehed\\DbalLogger\\QueryLogger` (the API remains the same).\n\nSetup for DBAL/ORM is different; that's inherent to the deprecation that prompted the creation of this library.\n\nThe port of the original SQLLogger did not have native return types, instead favoring docblocks.\nThis adds an explicit return type to the interface.\n\nThere's a new `DbalLogger` interface which your logger can also implement, creating hooks for `connect()` and `disconnect()` events.\nThis is optional, and if you want a low-effort conversion, it's fine to stick with the basic `QueryLogger` interface.\n\nThe `SAVEPOINT` queries either will show up in their underlying connection-specific syntax or possibly not at all.\nI'm not sure how to test this!\n(doctrine/dbal/src/Connection.php and thereabouts)\n\n## How to use this\nIf you have an implemenation of the DBAL SQLLogger interface (which is probably the case if you're here), you'll need to make the following changes:\n\n- Have it implement `Firehed\\DbalLogger\\QueryLogger` instead of `Doctrine\\DBAL\\Logging\\SQLLogger`\n- Wrap it in Middleware: `$middleware = new Firehed\\DbalLogger\\Middleware($yourQueryLogger);`\n- Adjust your DBAL/Doctrine setup code to use the Middleware instead of directly using the Logger:\n```diff\n-$config-\u003esetSQLLogger($yourSQLLogger);\n+$config-\u003esetMiddlewares([$middleware]);\n```\n\nIf you _don't_ have a SQLLogger implementation you're looking to migrate, you'll want create one!\n\n1) Implement `Firehed\\Dbal\\QueryLogger` or `Firehed\\DbalLogger\\DbalLogger`\n2) Wrap it in a middleware: `$middleware = new \\Fireheed\\DbalLogger\\Middleware($instanceOfYourClass);`\n3) Add it to the DBAL/Doctrine config, per above.\n\nThat should do it!\n\n## I need to log to multiple backends!\n\nNo problem - there's a built in `ChainLogger` that accepts an array of `QueryLogger`/`DbalLogger` instances.\nWhen configured, it will relay all of the logging events it receives to each of the loggers.\n\n```php\n$logger1 = new MyLogger();\n$logger2 = new MyOtherLogger(); // Maybe metrics?\n$chain = new ChainLogger([$logger1, $logger2]);\n$config-\u003esetMiddlewares([new LoggerMiddleware($chain)])\n```\n\n## Misc\n\nThis project follows semantic versioning.\n\nPlease use Github for reporting any issues or making any feature requests.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffirehed%2Fdoctrine-dbal-logging-middleware","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffirehed%2Fdoctrine-dbal-logging-middleware","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffirehed%2Fdoctrine-dbal-logging-middleware/lists"}