Skip to content

Commit 564467e

Browse files
committed
Feature: Ability to toggle web logging
1 parent a30c91c commit 564467e

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

jupyter_matlab_proxy/app.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,8 @@ def main():
414414
loop = asyncio.get_event_loop()
415415

416416
# Override default loggers
417-
runner = web.AppRunner(app, logger=logger, access_log=logger)
417+
web_logger = None if not mwi_env.is_web_logging_enabled() else logger
418+
runner = web.AppRunner(app, logger=web_logger, access_log=web_logger)
418419

419420
loop.run_until_complete(runner.setup())
420421
site = web.TCPSite(

jupyter_matlab_proxy/mwi_environment_variables.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ def get_env_name_logging_level():
1919
return "MWI_LOG_LEVEL"
2020

2121

22+
def get_env_name_web_logging_enabled():
23+
"""Enable the logging of asyncio web traffic by setting to true"""
24+
return "MWI_WEB_LOGGING_ENABLED"
25+
26+
2227
def get_env_name_log_file():
2328
"""Specifies a file into which logging content is directed"""
2429
return "MWI_LOG_FILE"
@@ -78,3 +83,8 @@ def is_testing_mode_enabled():
7883
is_development_mode_enabled()
7984
and os.environ.get(get_env_name_testing(), "false").lower() == "true"
8085
)
86+
87+
88+
def is_web_logging_enabled():
89+
"""Returns true if the web logging is required to be enabled"""
90+
return os.environ.get(get_env_name_web_logging_enabled(), "false") == "true"

0 commit comments

Comments
 (0)