HENNGE / arsenic

Async WebDriver implementation for asyncio and asyncio-compatible frameworks
Other
349 stars 52 forks source link

logging - printing the whole HTML text from a request is not 'INFO' #124

Open hexdex22 opened 3 years ago

hexdex22 commented 3 years ago

The volume of logging output from this library is unbearable. A simple request outputs hundreds of lines of HTML. Real errors and messages get buried in 'INFO'

Please fix this issue or supply a simple workaround.

Have tried workarounds suggested by others and read the structlog documentation - didn't work :(

Thanks,

Raj

P.S. I'm new to programming so might have missed something.

dimaqq commented 3 years ago

PRs are welcome!

hexdex22 commented 3 years ago

Horrible workaround that does reduce the amount of logger output:

In the files connection.py, errors.py and subprocess.py

Under the existing line: log = get_logger() Add the line log.info = lambda *args, **kwargs: True

This will overwrite the original log.info method.

Hope this helps.

seventh-attempt commented 3 years ago

I did it like this

from contextlib import redirect_stderr, redirect_stdout
import os

with open(os.devnull, 'w') as null_output_file:
    # redirects all info- and error- level output to null
    with redirect_stderr(null_output_file), redirect_stdout(null_output_file):
        func_that_uses_arsenic(params)

This code significantly reduces the amount of output, though some messages, like Only local connections are allowed. are still present in the console.

dejmail commented 1 year ago

I turned down the logging level of structlog like this -

import structlog
    structlog.configure(
    wrapper_class=structlog.make_filtering_bound_logger(logging.ERROR),
    )