-
Notifications
You must be signed in to change notification settings - Fork 49
feat(logger): Implement custom logger injection for Typesense client #113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR implements custom logger injection support for the Typesense PHP client, allowing users to provide their own PSR-3 compatible logger instead of relying on the default Monolog logger. This enhancement improves flexibility for users who want to integrate Typesense logging with their existing logging infrastructure.
Changes:
- Modified
Configurationclass to accept and validate custom PSR-3 logger instances via theloggerconfiguration option - Added comprehensive test coverage for logger injection scenarios including custom loggers, log levels, and edge cases
- Provided a working example demonstrating both custom logger usage and default logger configuration
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/Lib/Configuration.php | Implements custom logger injection with PSR-3 interface validation, falling back to default Monolog logger when no custom logger is provided |
| tests/Feature/ConfigurationTest.php | Comprehensive test suite covering default logger, custom logger, custom log levels, mock loggers, invalid logger handling, and configuration validation |
| examples/custom_logger.php | Example demonstrating custom logger injection and default logger configuration patterns |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@jkobus thank you for the PR! Was the Copilot review requested by you, or did this happen without your consent? |
I think I accidentally brought mine here :-) |
No worries if that was the case, I just feel like AI reviews tend to bring visual noise with them and didn't want them start reviewing every PR out of nowhere haha |
|
Added |
Change Summary
The Typesense PHP client now supports injecting your own PSR-3 compatible logger instance instead of using the default Monolog logger.
Usage
With Custom Logger
You can pass any PSR-3 compatible logger instance via the
loggerconfiguration option:Compatible Loggers
Any PSR-3 compliant logger will work:
Default Behavior
If you don't provide a custom logger, the client will create a default Monolog logger that writes to stdout:
Implementation Details
The change was made in
src/Lib/Configuration.php:This ensures backward compatibility - existing code will continue to work without any changes.
Example
See
examples/custom_logger.phpfor a complete working example.PR Checklist