Skip to content
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

Add support for external logger #5905

Closed

Conversation

BlairCooper
Copy link

@BlairCooper BlairCooper commented Jul 30, 2024


name: ⚙ Add support for external logger
labels: type/enhancement
about: Added support for both XML and CLI definition of an external logger. This --log-external option adds similar functionality that existed with the --printer option in 9.x and earlier.

resolve #5903

Implementations of an external logger do need to implement the \PHPUnit\Logger\ExternalLogger interface and must use the PHPUnit 10.x and later event mechanism for capturing logging events.

Added support for both XML and CLI definition of an external logger.
This --log-external option adds simialar functionality that existed with
the --printer option in 9.x and earlier.

Implementations of an external logger do need to implement the
\PHPUnit\Logger\ExternalLogger interface and must use the PHPUnit 10.x
and later event mechanism for capturing logging events.
@sebastianbergmann
Copy link
Owner

Thank you for your contribution. I appreciate the time you invested in preparing this pull request. However, I have decided not to merge it. Let me explain.

A test runner extension can use the replacesProgressOutput(), replacesResultOutput(), and replacesOutput() methods in its bootstrap() method to communicate to PHPUnit's test runner that it replaces the default output, in whole or in part. Just loading such an extension replaces PHPUnit's output and therefore achieves the same effect that the old --printer CLI option had.

So far, extensions can only be configured in PHPUnit's XML configuration file. There is no CLI option to load/configure an extension.

I think that a better solution in general and to your use case in particular would be to introduce a CLI option --extension <className> that allows registering a test runner extension on the CLI. <className> would be the name of a class that implements the PHPUnit\Runner\Extension\Extension interface. I woll work on this in #5906.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

--printer replacement in PHPUnit 10.x/11.x
2 participants