Skip to content

chore: remove withLogging #1804

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

Merged
merged 3 commits into from
Jun 13, 2025
Merged

chore: remove withLogging #1804

merged 3 commits into from
Jun 13, 2025

Conversation

Skn0tt
Copy link
Member

@Skn0tt Skn0tt commented Jun 12, 2025

No description provided.

@Skn0tt Skn0tt requested a review from yury-s June 12, 2025 10:39
@Skn0tt Skn0tt self-assigned this Jun 12, 2025
@yury-s yury-s requested a review from Copilot June 12, 2025 17:27
Copy link

@Copilot Copilot AI left a 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 chore PR removes occurrences of withLogging wrappers from the codebase in favor of direct calls. The change simplifies the code by eliminating extra logging instrumentation in various API and implementation methods.

  • Removed withLogging wrappers in RequestImpl, PageImpl, MouseImpl, KeyboardImpl, JSHandleImpl, FrameImpl, and several other modules.
  • Deprecated logging support methods and inline logging helper functions have been either removed or left as no-ops.

Reviewed Changes

Copilot reviewed 28 out of 28 changed files in this pull request and generated no comments.

Show a summary per file
File Description
playwright/src/main/java/com/microsoft/playwright/impl/RequestImpl.java Removed withLogging wrappers from header and response methods.
playwright/src/main/java/com/microsoft/playwright/impl/PageImpl.java Removed withLogging wrappers from various page interactions.
playwright/src/main/java/com/microsoft/playwright/impl/MouseImpl.java Simplified mouse operations by eliminating withLogging.
playwright/src/main/java/com/microsoft/playwright/impl/LoggingSupport.java Removed logging helper methods that wrap code execution.
playwright/src/main/java/com/microsoft/playwright/impl/LocatorImpl.java WithLogging removed from locator interaction methods.
... and others Consistent removal of withLogging across the codebase.
Comments suppressed due to low confidence (2)

playwright/src/main/java/com/microsoft/playwright/impl/LoggingSupport.java:19

  • Since withLogging wrappers are removed across the codebase, consider removing any remaining unused logging-related methods and imports (e.g. Supplier) from LoggingSupport to clean up the code further.
import java.util.function.Supplier;

playwright/src/main/java/com/microsoft/playwright/impl/ChannelOwner.java:82

  • The deprecated withLogging method override remains in ChannelOwner; once all call sites are updated, it would be beneficial to remove this method to reduce clutter.
/* Deprecated withLogging override */

@@ -53,7 +53,7 @@ public APIResponse delete(String url, RequestOptions options) {

@Override
public void dispose(DisposeOptions options) {
withLogging("APIRequestContext.dispose", () -> disposeImpl(options));
disposeImpl(options);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can now inline disposeImpl, it was required to make options non-const. Similar comment applies to the other methods that call fooImpl, except those that share the implementation (e.g. fetchImpl).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it was required to make options non-const

I don't understand what "making something non-const" means. Is that a Java specific thing? Can't find anything online about it, either.

dispose!

Done, I think I caught everything.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand what "making something non-const" means. Is that a Java specific thing? Can't find anything online about it, either.

Java requires variables referenced from the closures to be final, either explicitly or the compiler should be able to prove that. First thing disposeImpl does is a potential modification of options:

    if (options == null) {
      options = new DisposeOptions();
    }

For that assignment to work, options must not be final.

return result;
} finally {
if (isEnabled) {
logApi("<= " + apiName + (success ? " succeeded" : " failed"));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, this way DEBUG=pw:api is not useful any more. How do we handle it in Node.js, is it only logged on the server side now?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only logs outside of the server dir in Node.js: https://github.com/search?q=repo%3Amicrosoft%2Fplaywright+debugLogger.+NOT+path%3A%2F%5Epackages%5C%2Fplaywright-core%5C%2Fsrc%5C%2Fserver%5C%2F%2F&type=code
Looks to me like it's all on the server side now, yep.


<T> T withLogging(String apiName, Supplier<T> code) {
if (isEnabled) {
logApi("=> " + apiName + " started");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is logApi called by anyone else? If not, we can remove it altogether.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, it's called in HARRouter#handle via logApiIfEnabled, and in WaitForEventLogger#log.

@Skn0tt Skn0tt requested a review from yury-s June 13, 2025 07:15
Copy link
Member

@yury-s yury-s left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thanks you!

@yury-s yury-s merged commit b4151b1 into microsoft:main Jun 13, 2025
16 of 19 checks passed
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.

2 participants