-
Notifications
You must be signed in to change notification settings - Fork 260
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
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 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 */
| @Override | ||
| public void dispose(DisposeOptions options) { | ||
| withLogging("APIRequestContext.dispose", () -> disposeImpl(options)); | ||
| disposeImpl(options); |
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.
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).
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.
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.
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.
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.
playwright/src/main/java/com/microsoft/playwright/impl/APIRequestImpl.java
Outdated
Show resolved
Hide resolved
playwright/src/main/java/com/microsoft/playwright/impl/BrowserContextImpl.java
Outdated
Show resolved
Hide resolved
playwright/src/main/java/com/microsoft/playwright/impl/BrowserContextImpl.java
Outdated
Show resolved
Hide resolved
| return result; | ||
| } finally { | ||
| if (isEnabled) { | ||
| logApi("<= " + apiName + (success ? " succeeded" : " failed")); |
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.
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?
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.
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"); |
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.
Is logApi called by anyone else? If not, we can remove it altogether.
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.
yep, it's called in HARRouter#handle via logApiIfEnabled, and in WaitForEventLogger#log.
yury-s
left a comment
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.
Nice, thanks you!
No description provided.