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

log_level not working #255

Closed
suyashjawale opened this issue Oct 21, 2021 · 6 comments
Closed

log_level not working #255

suyashjawale opened this issue Oct 21, 2021 · 6 comments
Assignees

Comments

@suyashjawale
Copy link
Contributor

self.driver = webdriver.Chrome(executable_path=ChromeDriverManager(cache_valid_range=10, log_level=0).install(),options=options)

I have use above arguments to silent the logs but its not working also I used

import os
os.environ['WDM_LOG_LEVEL'] = '0'

But nothing seems to work..
Any solution??

image

@aleksandr-kotlyar
Copy link
Collaborator

@suyashjawale what version of webdriver-manager do you use?

@suyashjawale
Copy link
Contributor Author

@suyashjawale what version of webdriver-manager do you use?

webdriver-manager 3.5.1

@suyashjawale
Copy link
Contributor Author

suyashjawale commented Oct 21, 2021

@suyashjawale what version of webdriver-manager do you use?

Modified some code in logger.py file and the logs are silent. Instead of setting logger level to 0 set it to 100.
https://stackoverflow.com/a/2267162/9807249

image

@aleksandr-kotlyar
Copy link
Collaborator

aleksandr-kotlyar commented Oct 21, 2021

I get the same result as you. With the code

import os
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager

def test():
    os.environ['WDM_LOG_LEVEL'] = '0'
    driver = webdriver.Chrome(ChromeDriverManager().install())
# console output 
$ pytest tests/test_.py 
=============================================================================== test session starts ================================================================================
platform darwin -- Python 3.7.2, pytest-6.2.5, py-1.10.0, pluggy-1.0.0
rootdir: /Users/user/GitHubProjects/webdriver_manager, configfile: pytest.ini
plugins: cov-3.0.0
collected 1 item                                                                                                                                                                   

tests/test_.py::test 
---------------------------------------------------------------------------------- live log call -----------------------------------------------------------------------------------
INFO     WDM:logger.py:24 

INFO     WDM:logger.py:24 ====== WebDriver manager ======
INFO     WDM:logger.py:24 /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --version
INFO     WDM:logger.py:24 Google Chrome 94.0.4606.81 

INFO     WDM:logger.py:24 Current google-chrome version is 94.0.4606
INFO     WDM:logger.py:24 Get LATEST chromedriver version for 94.0.4606 google-chrome
INFO     WDM:logger.py:24 Driver [/Users/user/.wdm/drivers/chromedriver/mac64/94.0.4606.61/chromedriver] found in cache
PASSED                                                                                                                                                                       [100%]

================================================================================ 1 passed in 2.40s =================================================================================

But interesting that when I use pytest-env plugin to set WDM_LOG_LEVEL=0 - then it works propely. Checkout:

pip3 install pytest-env
# pytest.ini 
[pytest]
env =
    WDM_LOG_LEVEL=0
# test.py
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager

def test():
    driver = webdriver.Chrome(ChromeDriverManager().install())
# console output
$ pytest tests/test_.py 
=============================================================================== test session starts ================================================================================
platform darwin -- Python 3.7.2, pytest-6.2.5, py-1.10.0, pluggy-1.0.0
rootdir: /Users/user/GitHubProjects/webdriver_manager, configfile: pytest.ini
plugins: env-0.6.2, cov-3.0.0
collected 1 item                                                                                                                                                                   

tests/test_.py .                                                                                                                                                             [100%]

================================================================================ 1 passed in 2.37s =================================================================================

@suyashjawale
Copy link
Contributor Author

Commented this line in my fork and the issue is resolved. Before passing value the _init_logger() initializes the loggers dictionary with logging.INFO level. which makes it unable to override the value.
Using pytest-env plugin wouldn't be useful for me, as I am using this library as third party lib for another library.
Pls review and publish new update.

@aleksandr-kotlyar
Copy link
Collaborator

@suyashjawale Thank you for your job! I hope your PR will be merged soon. Please update your PR description with linkt to this issue, like:

Closes #255

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

No branches or pull requests

2 participants