Comments (6)
I finally found the way to do it, it is actually quite simple (and present in the API doc):
service = services.Geckodriver(binary=GECKODRIVER, log_file=os.devnull)
from arsenic.
Quick fix
def set_arsenic_log_level(level = logging.WARNING):
# Create logger
logger = logging.getLogger('arsenic')
# We need factory, to return application-wide logger
def logger_factory():
return logger
structlog.configure(logger_factory=logger_factory)
logger.setLevel(level)
from arsenic.
The docs should do a better job here I agree. Arsenic uses structlog so for now please check their documentation on how to control output.
from arsenic.
I am encountering the same issue and can not manage to disable all logging to stdout even after reading the structlog manual.
Is there a chance someone has the solution ?
from arsenic.
In my case, I wanted to preserve logging by just trimming long values in methods like screenshot.
This could be achieved by custom processor:
class DictTrimmerProcessor:
def __init__(self, max_chars=25) -> None:
self.max_chars = max_chars
self.block_length = max_chars // 2 - 1
def __call__(self, logger, method_name, event_dict):
for field in event_dict:
if isinstance(event_dict[field], dict):
val = deepcopy(event_dict[field]) # Copy so that original event_dict is not changed
for key in val:
if isinstance(val[key], str) and len(val[key]) > self.max_chars:
val[key] = f"{val[key][:self.block_length]}...{val[key][-self.block_length:]}"
event_dict[field] = val
return event_dict
def fix_arsenic_log():
processors = structlog.get_config().get("processors", [])
processors.insert(0, DictTrimmerProcessor())
structlog.configure(processors=processors)
Hope someone finds this helpful since this issue is first on google when searching for logging problems in arsenic.
from arsenic.
Using Python 3.10.7 and arsenic 21.8 on Windows 10 here. The confusing part is that arsenic, geckodriver and Firefox all emit info logs to the console, so I had do to quite a few things to turn the noise off:
- Comment out all log.info() in <your python install path>\Lib\site-packages\arsenic\connection.py on my machine
- Initiate arsenic using the following code (and remove -headless and -private if you don't need them)
service = arsenic.services.Geckodriver(log_file=os.devnull)
browser = arsenic.browsers.Firefox(**{'moz:firefoxOptions': {'args': ['-headless', '-private'], 'log': {'level': 'warn'}}})
I hope this will help someone, and I hope the arsenic developers will give us an option to turn off the logs in future releases
from arsenic.
Related Issues (20)
- get_attribute("innerHTML") stopped working (chrome) HOT 3
- compatibility issue when asyncio loop policy is not the default one HOT 7
- Any way to controle several tabs async? HOT 2
- How to get page title? HOT 1
- arsenic doesnโt support all ChromeOptions? HOT 3
- Unable to open URLs with chrome driver at all? HOT 1
- Unable to set prefs in arsenic similar to selenium (download files to default directory)
- Any way to avoid close chrome after execution HOT 4
- How does this compare to playwright? HOT 1
- AttributeError: 'str' object has no attribute 'fileno' HOT 1
- Spawning Chrome/Edge browser in Windows from WSL2
- Asyncio TimeoutError HOT 1
- Unable to run tests because of broken dependency
- Post-merge CI build fails HOT 2
- Shall we try goodfirstissue.dev ?
- Getting 'unknown error: net::ERR_CONNECTION_CLOSED' Error HOT 4
- Cloudflare detection HOT 1
- No requirements.txt file and couldn't run the tests with Pytest HOT 5
- FileNotFoundError: [WinError 2] The system cannot find the file specified HOT 5
- Remove distutils HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from arsenic.