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

Change Ruby Logging #11967

Merged
merged 6 commits into from May 6, 2023
Merged

Change Ruby Logging #11967

merged 6 commits into from May 6, 2023

Conversation

titusfortner
Copy link
Member

Description

Change default logging level to :info and provide more granular filtering options

Motivation and Context

I'm looking at how logging is being done in other languages, and as part of putting this documentation together - https://www.selenium.dev/documentation/webdriver/troubleshooting/logging/ I thought we should change our implementation to match the other languages.

Details:

To better manage the flood of details now in :debug mode, I've added #select and #reject methods where you can opt in or opt out of specific types of logs.

Selenium::WebDriver.logger.level = :debug
Selenium::WebDriver.logger.select(:selenium_manager)
Selenium::WebDriver.logger.reject(%i[deprecations logger_info])

Let me know if all of these choices make sense.

@p0deje
Copy link
Member

p0deje commented Apr 28, 2023

I'm looking through https://www.selenium.dev/documentation/webdriver/troubleshooting/logging/, but I don't see what exactly we should match in Ruby. Can you point to Java/Python/etc examples?

@titusfortner
Copy link
Member Author

I meant the levels.

  • Actionable items
  • Useful information
  • Debugging details

Right now :warn is a mix of info and actionable
And :info is essentially another level of :debug details

I wish Ruby had more "debug" levels like the other languages, but alas.

rb/lib/selenium/webdriver/common/logger.rb Outdated Show resolved Hide resolved
#
# @param [Array, Symbol] id
#
def select(id)
Copy link
Member

Choose a reason for hiding this comment

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

Ditto.

rb/lib/selenium/webdriver/common/logger.rb Outdated Show resolved Hide resolved

warn message, &block
@logger.warn { message }
Copy link
Member

Choose a reason for hiding this comment

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

The code is very similar to #discard_or_log. I suggest you refactor it so that it accepts @reject/@select as the parameters. Then you can simply call this method with an extra :deprecations id.

rb/lib/selenium/webdriver/common/logger.rb Outdated Show resolved Hide resolved
@titusfortner
Copy link
Member Author

I fixed the things you suggested, including changing the names. I'd prefer Arrays to Sets still just because that's what people are more used to... Methods now accept one or more params and Arrays.

I also added logic for setting the default level in constructor. Webdrivers gem and Watir both use the Selenium Logger, and don't want to force the change on them?

@p0deje
Copy link
Member

p0deje commented May 3, 2023

I fixed the things you suggested, including changing the names. I'd prefer Arrays to Sets still just because that's what people are more used to... Methods now accept one or more params and Arrays.

My proposal was to convert arrays to sets internally, not to force people into using sets.

Copy link
Member

@p0deje p0deje left a comment

Choose a reason for hiding this comment

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

LGTM but CI is failing.

@titusfortner titusfortner force-pushed the log_rb branch 3 times, most recently from 06dec92 to fb6622f Compare May 6, 2023 02:19
@titusfortner titusfortner merged commit e4e6362 into trunk May 6, 2023
2 of 3 checks passed
@titusfortner titusfortner deleted the log_rb branch May 6, 2023 03:33
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.

None yet

2 participants