Skip to content

Commit c8506e5

Browse files
authored
Ref #3515: log more and expose more settings in root URL (#3522)
1 parent 13cfcb6 commit c8506e5

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

kinto/plugins/history/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from pyramid.settings import aslist
2+
13
from kinto.authorization import PERMISSIONS_INHERITANCE_TREE
24
from kinto.core import metrics
35
from kinto.core.events import ResourceChanged
@@ -6,10 +8,18 @@
68

79

810
def includeme(config):
11+
settings = config.get_settings()
12+
exposed_settings = {}
13+
if (trim_history_max := int(settings.get("history.auto_trim_max_count", "-1"))) > 0:
14+
exposed_settings["auto_trim_max_count"] = trim_history_max
15+
if trim_user_ids := aslist(settings.get("history.auto_trim_user_ids", "")):
16+
exposed_settings["auto_trim_user_ids"] = trim_user_ids
17+
918
config.add_api_capability(
1019
"history",
1120
description="Track changes on data.",
1221
url="http://kinto.readthedocs.io/en/latest/api/1.x/history.html",
22+
**exposed_settings,
1323
)
1424

1525
# Activate end-points.

kinto/plugins/history/listener.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,15 @@ def on_resource_changed(event):
162162
filters=filters
163163
+ [Filter("last_modified", trim_before_timestamp, COMPARISON.MAX)],
164164
)
165-
logger.debug(f"Trimmed {len(deleted)} old history entries.")
165+
logger.info(f"Trimmed {len(deleted)} old history entries.")
166+
else:
167+
logger.info(
168+
"No old history to trim for {user_id!r} on {resource_name!r} in {bucket_uri!r}."
169+
)
170+
else:
171+
logger.info(
172+
f"Trimming of old history entries is not enabled{f' for {user_id!r}.' if is_trim_enabled else '.'}"
173+
)
166174

167175
# Without explicit permissions, the ACLs on the history entries will
168176
# fully depend on the inherited permission tree (eg. bucket:read, bucket:write).

0 commit comments

Comments
 (0)