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

Silencing outut #287

Open
edoardo-c opened this issue Dec 1, 2023 · 0 comments
Open

Silencing outut #287

edoardo-c opened this issue Dec 1, 2023 · 0 comments
Labels

Comments

@edoardo-c
Copy link

Hello,

It seems I am not alone in trying to silence STDOUT output.

The following is an extract of my code:

if success:
    try:
        api_connection.start()
        result = api_request(*args, **kwargs)
        return True, result
    except Exception as e:
        logger.error(f"API request exception:\n{e}")
        return False, None
    finally:
        api_connection.stop()
else:
    logger.error(f"SSH tunnel failed to establish")

When the tunnel fails on api_connection.start() because it is already running, I get an entry in the logs

[ERROR] API request exception:
...

but I also get an output to STDOUT even though default logging is set to INFO and I also attempted to add a specific log level for sshtunnel

logging.getLogger('sshtunnel').setLevel(logging.WARNING)
logging.getLogger("sshtunnel.SSHTunnelForwarder").setLevel(logging.WARNING)

The output to STDOUT

ERROR   | Problem setting SSH Forwarder up: Couldn't open tunnel foo:XX <> bar:XX might be in use or destination not reachable

What can I do for all sshtunnel output to go to logs rather than STDOUT to keep my output informative and clean?

Thanks!
Ed

@pahaz pahaz added the bug label May 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants