Skip to content

Commit

Permalink
Log user agent.
Browse files Browse the repository at this point in the history
  • Loading branch information
terjekv committed Nov 20, 2024
1 parent 2fc1537 commit 44acbf5
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion mreg/middleware/logging_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def __call__(self, request: HttpRequest) -> HttpResponse:
:param request: The incoming request.
:return: A response object
"""
start_time = time.time()
start_time = int(time.time())

self.log_request(request)
response = self.get_response(request)
Expand Down Expand Up @@ -98,13 +98,16 @@ def log_request(self, request: HttpRequest) -> None:
else:
proxy_ip = ""

user_agent = self._get_request_header(request, "user-agent", "HTTP_USER_AGENT")

# Size of request
request_size = len(request.body)

mreg_logger.bind(
method=request.method,
remote_ip=remote_ip,
proxy_ip=proxy_ip,
user_agent=user_agent,
path=request.path_info,
query_string=request.META.get("QUERY_STRING"),
request_size=request_size,
Expand Down

0 comments on commit 44acbf5

Please sign in to comment.