dev-proxy-logging: Disable dev proxy logging by default.

- Add parameter to proxy launchig script, which enables logging
  for dev proxy server (disabled by default).
This commit is contained in:
K.Kanakhin 2016-12-19 15:47:46 +06:00
parent 75340c93b0
commit 4750d30341
1 changed files with 13 additions and 4 deletions

View File

@ -62,6 +62,10 @@ parser.add_option('--force', dest='force',
action="store_true",
default=False, help='Run tests despite possible problems.')
parser.add_option('--enable-tornado-logging', dest='enable_tornado_logging',
action="store_true",
default=False, help='Enable access logs from tornado proxy server.')
(options, arguments) = parser.parse_args()
if not options.force:
@ -325,8 +329,8 @@ class TornadoHandler(CombineHandler):
class Application(web.Application):
def __init__(self):
# type: () -> None
def __init__(self, enable_logging=False):
# type: (bool) -> None
handlers = [
(r"/json/events.*", TornadoHandler),
(r"/api/v1/events.*", TornadoHandler),
@ -335,7 +339,12 @@ class Application(web.Application):
(r"/socket.io.*", WebPackHandler),
(r"/.*", DjangoHandler)
]
super(Application, self).__init__(handlers)
super(Application, self).__init__(handlers, enable_logging=enable_logging)
def log_request(self, handler):
# type: (BaseWebsocketHandler) -> None
if self.settings['enable_logging']:
super(Application, self).log_request(handler)
def on_shutdown():
@ -364,7 +373,7 @@ print("".join((WARNING,
proxy_port), ENDC)))
try:
app = Application()
app = Application(enable_logging=options.enable_tornado_logging)
app.listen(proxy_port, address=options.interface)
ioloop = IOLoop.instance()
for s in (signal.SIGINT, signal.SIGTERM):