use pythons logging infrastructure

This commit is contained in:
Jakob Ketterl
2019-05-10 21:50:58 +02:00
parent 6243a297c0
commit e15359a106
6 changed files with 44 additions and 26 deletions

View File

@ -2,6 +2,9 @@ from owrx.controllers import StatusController, IndexController, AssetsController
from http.server import BaseHTTPRequestHandler
import re
import logging
logger = logging.getLogger(__name__)
class RequestHandler(BaseHTTPRequestHandler):
def __init__(self, request, client_address, server):
self.router = Router()
@ -29,9 +32,9 @@ class Router(object):
return (m["controller"], matches)
def route(self, handler):
res = self.find_controller(handler.path)
#print("path: {0}, controller: {1}, matches: {2}".format(handler.path, controller, matches))
if res is not None:
(controller, matches) = res
logger.debug("path: {0}, controller: {1}, matches: {2}".format(handler.path, controller, matches))
controller(handler, matches).handle_request()
else:
handler.send_error(404, "Not Found", "The page you requested could not be found.")