mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 15:03:34 +00:00
logging_util: Remove dependence on get_current_request.
Pass the HttpRequest explicitly through the two webhooks that log to
the webhook loggers.
get_current_request is now unused, so remove it (in the same commit
for test coverage reasons).
Signed-off-by: Anders Kaseorg <anders@zulip.com>
(cherry picked from commit 63be67af80)
This commit is contained in:
committed by
Alex Vandiver
parent
cc21dc8ec7
commit
406f9f7852
@@ -11,6 +11,7 @@ from typing import Optional, Tuple, Union
|
||||
import orjson
|
||||
from django.conf import settings
|
||||
from django.core.cache import cache
|
||||
from django.http import HttpRequest
|
||||
from django.utils.timezone import now as timezone_now
|
||||
|
||||
|
||||
@@ -217,10 +218,8 @@ class ZulipWebhookFormatter(ZulipFormatter):
|
||||
return "\n".join(multiline)
|
||||
|
||||
def format(self, record: logging.LogRecord) -> str:
|
||||
from zerver.lib.request import get_current_request
|
||||
|
||||
request = get_current_request()
|
||||
if not request:
|
||||
request: Optional[HttpRequest] = getattr(record, "request", None)
|
||||
if request is None:
|
||||
record.user = None
|
||||
record.client = None
|
||||
record.url = None
|
||||
|
||||
Reference in New Issue
Block a user