forked from MirrorHub/synapse
Log more when we have processed the request
This commit is contained in:
parent
b5209c5744
commit
cee69441d3
4 changed files with 23 additions and 4 deletions
|
@ -370,6 +370,8 @@ class Auth(object):
|
||||||
user_agent=user_agent
|
user_agent=user_agent
|
||||||
)
|
)
|
||||||
|
|
||||||
|
request.authenticated_entity = user.to_string()
|
||||||
|
|
||||||
defer.returnValue((user, ClientInfo(device_id, token_id)))
|
defer.returnValue((user, ClientInfo(device_id, token_id)))
|
||||||
except KeyError:
|
except KeyError:
|
||||||
raise AuthError(
|
raise AuthError(
|
||||||
|
|
|
@ -143,6 +143,7 @@ class SynapseHomeServer(HomeServer):
|
||||||
port = listener_config["port"]
|
port = listener_config["port"]
|
||||||
bind_address = listener_config.get("bind_address", "")
|
bind_address = listener_config.get("bind_address", "")
|
||||||
tls = listener_config.get("tls", False)
|
tls = listener_config.get("tls", False)
|
||||||
|
site_tag = listener_config.get("tag", port)
|
||||||
|
|
||||||
if tls and config.no_tls:
|
if tls and config.no_tls:
|
||||||
return
|
return
|
||||||
|
@ -199,6 +200,7 @@ class SynapseHomeServer(HomeServer):
|
||||||
port,
|
port,
|
||||||
SynapseSite(
|
SynapseSite(
|
||||||
"synapse.access.https",
|
"synapse.access.https",
|
||||||
|
site_tag,
|
||||||
listener_config,
|
listener_config,
|
||||||
root_resource,
|
root_resource,
|
||||||
),
|
),
|
||||||
|
@ -210,6 +212,7 @@ class SynapseHomeServer(HomeServer):
|
||||||
port,
|
port,
|
||||||
SynapseSite(
|
SynapseSite(
|
||||||
"synapse.access.https",
|
"synapse.access.https",
|
||||||
|
site_tag,
|
||||||
listener_config,
|
listener_config,
|
||||||
root_resource,
|
root_resource,
|
||||||
),
|
),
|
||||||
|
@ -458,6 +461,9 @@ class SynapseRequest(Request):
|
||||||
self.uri
|
self.uri
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def get_user_agent(self):
|
||||||
|
return self.requestHeaders.getRawHeaders("User-Agent", [None])[-1]
|
||||||
|
|
||||||
|
|
||||||
class XForwardedForRequest(SynapseRequest):
|
class XForwardedForRequest(SynapseRequest):
|
||||||
def __init__(self, *args, **kw):
|
def __init__(self, *args, **kw):
|
||||||
|
@ -494,11 +500,11 @@ class SynapseSite(Site):
|
||||||
Subclass of a twisted http Site that does access logging with python's
|
Subclass of a twisted http Site that does access logging with python's
|
||||||
standard logging
|
standard logging
|
||||||
"""
|
"""
|
||||||
def __init__(self, logger_name, config, resource, *args, **kwargs):
|
def __init__(self, logger_name, tag, config, resource, *args, **kwargs):
|
||||||
Site.__init__(self, resource, *args, **kwargs)
|
Site.__init__(self, resource, *args, **kwargs)
|
||||||
|
|
||||||
proxied = config.get("x_forwarded", False)
|
proxied = config.get("x_forwarded", False)
|
||||||
self.requestFactory = SynapseRequestFactory(None, proxied)
|
self.requestFactory = SynapseRequestFactory(tag, proxied)
|
||||||
|
|
||||||
if proxied:
|
if proxied:
|
||||||
self._log_formatter = proxiedLogFormatter
|
self._log_formatter = proxiedLogFormatter
|
||||||
|
|
|
@ -94,6 +94,7 @@ class TransportLayerServer(object):
|
||||||
yield self.keyring.verify_json_for_server(origin, json_request)
|
yield self.keyring.verify_json_for_server(origin, json_request)
|
||||||
|
|
||||||
logger.info("Request from %s", origin)
|
logger.info("Request from %s", origin)
|
||||||
|
request.authenticated_entity = origin
|
||||||
|
|
||||||
defer.returnValue((origin, content))
|
defer.returnValue((origin, content))
|
||||||
|
|
||||||
|
|
|
@ -125,8 +125,18 @@ def request_handler(request_handler):
|
||||||
code = str(code) if code else "-"
|
code = str(code) if code else "-"
|
||||||
end = self.clock.time_msec()
|
end = self.clock.time_msec()
|
||||||
logger.info(
|
logger.info(
|
||||||
"Processed request: %dms %s %s %s",
|
"%s - %s - {%s}"
|
||||||
end-start, code, request.method, request.path
|
" Processed request: %dms %sB %s \"%s %s %s\" \"%s\"",
|
||||||
|
request.getClientIP(),
|
||||||
|
request.site_tag,
|
||||||
|
request.authenticated_entity,
|
||||||
|
end-start,
|
||||||
|
request.sentLength,
|
||||||
|
code,
|
||||||
|
request.method,
|
||||||
|
request.get_redacted_uri(),
|
||||||
|
request.clientproto,
|
||||||
|
request.get_user_agent(),
|
||||||
)
|
)
|
||||||
return wrapped_request_handler
|
return wrapped_request_handler
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue