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

logger can't be disabled #158

Closed
buckle2000 opened this issue Dec 23, 2019 · 2 comments
Closed

logger can't be disabled #158

buckle2000 opened this issue Dec 23, 2019 · 2 comments
Assignees

Comments

@buckle2000
Copy link

buckle2000 commented Dec 23, 2019

The following code treats logger=False as logger=True.

if not isinstance(logger, bool):
self.logger = logger
else:
self.logger = default_logger
if not logging.root.handlers and \
self.logger.level == logging.NOTSET:
if logger:
self.logger.setLevel(logging.INFO)
else:
self.logger.setLevel(logging.ERROR)
self.logger.addHandler(logging.StreamHandler())

The docstring says otherwise:

:param logger: To enable logging set to ``True`` or pass a logger object to
use. To disable logging set to ``False``. The default is
``False``.

@buckle2000
Copy link
Author

buckle2000 commented Dec 23, 2019

This is the same for server of this module and client and server of python-socketio.

A simple work around is to use unittest.mock.Mock

@miguelgrinberg
Copy link
Owner

Errors cannot be disabled, setting logger to False just silences anything below ERROR level. But you are correct in that the documentation does not explain this, I'll fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants