1
0
Fork 0
mirror of https://github.com/Kozea/Radicale.git synced 2025-08-01 18:18:31 +00:00

add suppress log messages

This commit is contained in:
Peter Bieringer 2024-06-18 08:24:25 +02:00
parent d83885d108
commit defa767c8a
4 changed files with 11 additions and 1 deletions

View file

@ -145,6 +145,8 @@ class Application(ApplicationPartDelete, ApplicationPartHead,
if isinstance(answer, str): if isinstance(answer, str):
if self._response_content_on_debug: if self._response_content_on_debug:
logger.debug("Response content:\n%s", answer) logger.debug("Response content:\n%s", answer)
else:
logger.debug("Response content: suppressed by config/option [auth] response_content_on_debug")
headers["Content-Type"] += "; charset=%s" % self._encoding headers["Content-Type"] += "; charset=%s" % self._encoding
answer = answer.encode(self._encoding) answer = answer.encode(self._encoding)
accept_encoding = [ accept_encoding = [
@ -191,8 +193,10 @@ class Application(ApplicationPartDelete, ApplicationPartHead,
request_method, unsafe_path, depthinfo, request_method, unsafe_path, depthinfo,
remote_host, remote_useragent) remote_host, remote_useragent)
if self._request_header_on_debug: if self._request_header_on_debug:
logger.debug("Request headers:\n%s", logger.debug("Request header:\n%s",
pprint.pformat(self._scrub_headers(environ))) pprint.pformat(self._scrub_headers(environ)))
else:
logger.debug("Request header: suppressed by config/option [auth] request_header_on_debug")
# SCRIPT_NAME is already removed from PATH_INFO, according to the # SCRIPT_NAME is already removed from PATH_INFO, according to the
# WSGI specification. # WSGI specification.

View file

@ -75,6 +75,8 @@ class ApplicationBase:
if self._response_content_on_debug: if self._response_content_on_debug:
logger.debug("Response content:\n%s", logger.debug("Response content:\n%s",
xmlutils.pretty_xml(xml_content)) xmlutils.pretty_xml(xml_content))
else:
logger.debug("Response content: suppressed by config/option [auth] response_content_on_debug")
f = io.BytesIO() f = io.BytesIO()
ET.ElementTree(xml_content).write(f, encoding=self._encoding, ET.ElementTree(xml_content).write(f, encoding=self._encoding,
xml_declaration=True) xml_declaration=True)

View file

@ -149,6 +149,8 @@ class ApplicationPartPut(ApplicationBase):
"Bad PUT request on %r (read_components): %s", path, e, exc_info=True) "Bad PUT request on %r (read_components): %s", path, e, exc_info=True)
if self._log_bad_put_request_content: if self._log_bad_put_request_content:
logger.warning("Bad PUT request content of %r:\n%s", path, content) logger.warning("Bad PUT request content of %r:\n%s", path, content)
else:
logger.debug("Bad PUT request content: suppressed by config/option [auth] bad_put_request_content")
return httputils.BAD_REQUEST return httputils.BAD_REQUEST
(prepared_items, prepared_tag, prepared_write_whole_collection, (prepared_items, prepared_tag, prepared_write_whole_collection,
prepared_props, prepared_exc_info) = prepare( prepared_props, prepared_exc_info) = prepare(

View file

@ -145,6 +145,8 @@ def read_request_body(configuration: "config.Configuration",
read_raw_request_body(configuration, environ)) read_raw_request_body(configuration, environ))
if configuration.get("logging", "request_content_on_debug"): if configuration.get("logging", "request_content_on_debug"):
logger.debug("Request content:\n%s", content) logger.debug("Request content:\n%s", content)
else:
logger.debug("Request content: suppressed by config/option [auth] request_content_on_debug")
return content return content