Skip to content

Commit

Permalink
logging functionality to socketio added and configured testing for cr…
Browse files Browse the repository at this point in the history
…itical erros (#1966)

* logging functionality to socketio added and configured testing for critical errors

* updated to ERROR
  • Loading branch information
ReimarBauer committed Sep 6, 2023
1 parent b5caeb7 commit 52f5d22
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 3 deletions.
6 changes: 6 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@ def pytest_generate_tests(metafunc):
# mscolab data directory
MSCOLAB_DATA_DIR = fs.path.join(DATA_DIR, 'filedata')
# To enable logging set to True or pass a logger object to use.
SOCKETIO_LOGGER = True
# To enable Engine.IO logging set to True or pass a logger object to use.
ENGINEIO_LOGGER = True
# used to generate and parse tokens
SECRET_KEY = secrets.token_urlsafe(16)
Expand Down
6 changes: 6 additions & 0 deletions docs/samples/config/mscolab/mscolab_settings.py.sample
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@
"""
import os

# To enable logging set to True or pass a logger object to use.
SOCKETIO_LOGGER = False

# To enable Engine.IO logging set to True or pass a logger object to use.
ENGINEIO_LOGGER = False

# Set which origins are allowed to communicate with your server
CORS_ORIGINS = ["*"]

Expand Down
6 changes: 6 additions & 0 deletions mslib/mscolab/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ class default_mscolab_settings:
# expire token in seconds
# EXPIRATION = 86400

# To enable logging set to True or pass a logger object to use.
SOCKETIO_LOGGER = False

# To enable Engine.IO logging set to True or pass a logger object to use.
ENGINEIO_LOGGER = False

# Which origins are allowed to communicate with your server
CORS_ORIGINS = ["*"]

Expand Down
3 changes: 2 additions & 1 deletion mslib/mscolab/sockets_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
from mslib.mscolab.utils import get_session_id
from mslib.mscolab.conf import mscolab_settings

socketio = SocketIO(cors_allowed_origins=("*" if not hasattr(mscolab_settings, "CORS_ORIGINS") or
socketio = SocketIO(logger=mscolab_settings.SOCKETIO_LOGGER, engineio_logger=mscolab_settings.ENGINEIO_LOGGER,
cors_allowed_origins=("*" if not hasattr(mscolab_settings, "CORS_ORIGINS") or
"*" in mscolab_settings.CORS_ORIGINS else mscolab_settings.CORS_ORIGINS))


Expand Down
9 changes: 7 additions & 2 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
[pytest]
log_format = %(asctime)s %(levelname)s %(message)s
log_date_format = %Y-%m-%d %H:%M:%S
log_cli = 1
log_cli_level = ERROR
log_cli_format = %(message)s
log_file = pytest.log
log_file_level = DEBUG
log_file_format = %(asctime)s %(levelname)s %(message)s
log_file_date_format = %Y-%m-%d %H:%M:%S
timeout = 60
filterwarnings =
# These namespaces are declared in a way not conformant with PEP420. Not much we can do about that here, we should keep an eye on when this is fixed in our dependencies though.
Expand Down

0 comments on commit 52f5d22

Please sign in to comment.