diff --git a/plinth/__main__.py b/plinth/__main__.py index 328484c17..d23a3d1a2 100644 --- a/plinth/__main__.py +++ b/plinth/__main__.py @@ -26,6 +26,7 @@ import logging import os import stat import sys +import warnings import cherrypy @@ -82,6 +83,15 @@ def setup_logging(): cherrypy.log.error_file = cfg.status_log_file cherrypy.log.access_file = cfg.access_log_file + # Capture all Python warnings such as deprecation warnings + logging.captureWarnings(True) + + # Log all deprecation warnings when in debug mode + if cfg.debug: + warnings.filterwarnings('default', '', DeprecationWarning) + warnings.filterwarnings('default', '', PendingDeprecationWarning) + warnings.filterwarnings('default', '', ImportWarning) + def setup_server(): """Setup CherryPy server"""