Skip to content

Commit c471b36

Browse files
committed
feat: disable HTTP access logs
1 parent 3fbc786 commit c471b36

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
Versions follow [Semantic Versioning](https://semver.org/>) (<major>.<minor>.<patch>).
99

10+
## [0.1.1] - 2025-04-04
11+
12+
### Changed
13+
14+
- Update to Canaille 0.0.70.
15+
- Disable http access logs.
16+
1017
## [0.1.0] - 2024-07-25
1118

1219
### Changed

pytest_iam/__init__.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import wsgiref.simple_server
66
from types import ModuleType
77
from typing import Any
8+
from wsgiref.simple_server import WSGIRequestHandler
89

910
import portpicker
1011
import pytest
@@ -36,11 +37,17 @@ class Server:
3637
backend: Backend
3738
"""The backend used to manage models."""
3839

39-
def __init__(self, app, port: int, backend: Backend):
40+
logging: bool = False
41+
"""Whether the request access log is enabled."""
42+
43+
def __init__(self, app, port: int, backend: Backend, logging: bool = False):
4044
self.app = app
4145
self.backend = backend
4246
self.port = port
43-
self.httpd = wsgiref.simple_server.make_server("localhost", port, app)
47+
self.logging = logging
48+
self.httpd = wsgiref.simple_server.make_server(
49+
"localhost", port, app, handler_class=self.make_request_handler()
50+
)
4451
self.models = models
4552
self.logged_user = None
4653

@@ -49,6 +56,16 @@ def logged_user():
4956
if self.logged_user:
5057
g.user = self.logged_user
5158

59+
def make_request_handler(self):
60+
server = self
61+
62+
class RequestHandler(WSGIRequestHandler):
63+
def log_request(self, code="-", size="-"):
64+
if server.logging:
65+
super().log_request(code, size)
66+
67+
return RequestHandler
68+
5269
@property
5370
def url(self) -> str:
5471
"""The URL at which the IAM server is accessible."""

0 commit comments

Comments
 (0)