diff --git a/plinth/web_server.py b/plinth/web_server.py index e7cb458d1..d22f11f51 100644 --- a/plinth/web_server.py +++ b/plinth/web_server.py @@ -72,8 +72,19 @@ def init(): 'engine.autoreload.match': AUTORELOAD_REGEX, }) + def _logging_middleware(application): + """A WSGI middleware to log messages before executing them.""" + + def _wrapper(environ, start_response): + """Log request, then hand control to original app.""" + logger.info("%s %s", environ['REQUEST_METHOD'], + environ['PATH_INFO']) + return application(environ, start_response) + + return _wrapper + application = web_framework.get_wsgi_application() - cherrypy.tree.graft(application, cfg.server_dir) + cherrypy.tree.graft(_logging_middleware(application), cfg.server_dir) static_dir = os.path.join(cfg.file_root, 'static') _mount_static_directory(static_dir, web_framework.get_static_url())