Skip to content
Snippets Groups Projects
Commit 5ca1a514 authored by Jeremy Bowman's avatar Jeremy Bowman
Browse files

PLAT-1350 Log Python warnings in production

parent 1eb8b3a9
No related branches found
Tags release-2019-07-03-11.16
No related merge requests found
"""
WSGI config for CMS.
This module contains the WSGI application used by Django's development server
and any production WSGI deployments.
It exposes a module-level variable named ``application``. Django's
``runserver`` and ``runfcgi`` commands discover this application via the
``WSGI_APPLICATION`` setting.
"""
from __future__ import absolute_import
from openedx.core.lib.logsettings import log_python_warnings
log_python_warnings()
# Patch the xml libs before anything else.
from safe_lxml import defuse_xml_libs
defuse_xml_libs()
......
......@@ -7,6 +7,10 @@ It exposes a module-level variable named ``application``. Django's
``runserver`` and ``runfcgi`` commands discover this application via the
``WSGI_APPLICATION`` setting.
"""
from __future__ import absolute_import
from openedx.core.lib.logsettings import log_python_warnings
log_python_warnings()
# Patch the xml libs
from safe_lxml import defuse_xml_libs
......
......@@ -4,6 +4,10 @@ Apache WSGI file for LMS
This module contains the WSGI application used for Apache deployment.
It exposes a module-level variable named ``application``.
"""
from __future__ import absolute_import
from openedx.core.lib.logsettings import log_python_warnings
log_python_warnings()
# Patch the xml libs before anything else.
from safe_lxml import defuse_xml_libs
......
......@@ -10,15 +10,21 @@ by passing the --settings flag, you can specify what environment specific settin
Any arguments not understood by this manage.py will be passed to django-admin.py
"""
# pylint: disable=wrong-import-order, wrong-import-position
from __future__ import absolute_import, print_function
from openedx.core.lib.logsettings import log_python_warnings
log_python_warnings()
# Patch the xml libs before anything else.
from safe_lxml import defuse_xml_libs
defuse_xml_libs()
import importlib
import os
import sys
import importlib
from argparse import ArgumentParser
import contracts
......@@ -82,8 +88,8 @@ def parse_args():
edx_args, django_args = parser.parse_known_args()
if edx_args.help:
print "edX:"
print edx_args.help_string
print("edX:")
print(edx_args.help_string)
return edx_args, django_args
......@@ -104,7 +110,7 @@ if __name__ == "__main__":
contracts.disable_all()
if edx_args.help:
print "Django:"
print("Django:")
# This will trigger django-admin.py to print out its help
django_args.append('--help')
......
"""Get log settings."""
import logging
import os
import platform
import sys
import warnings
from logging.handlers import SysLogHandler
LOG_LEVELS = ['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL']
......@@ -161,3 +163,15 @@ def get_logger_config(log_dir,
})
return logger_config
def log_python_warnings():
"""
Stop ignoring DeprecationWarning, ImportWarning, and PendingDeprecationWarning;
log all Python warnings to the main log file.
Not used in test runs, so pytest can collect the warnings triggered for
each test case.
"""
warnings.simplefilter('default')
logging.captureWarnings(True)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment