diff --git a/frappe/core/doctype/log_settings/log_settings.py b/frappe/core/doctype/log_settings/log_settings.py index a32535e109..7b8deb6ef7 100644 --- a/frappe/core/doctype/log_settings/log_settings.py +++ b/frappe/core/doctype/log_settings/log_settings.py @@ -10,20 +10,6 @@ from frappe.model.document import Document from frappe.utils import cint from frappe.utils.caching import site_cache -DEFAULT_LOGTYPES_RETENTION = { - "Error Log": 30, - "Activity Log": 90, - "Email Queue": 30, - "Scheduled Job Log": 90, - "Route History": 90, - "Submission Queue": 30, - "Prepared Report": 30, - "Webhook Request Log": 30, - "Integration Request": 90, - "Unhandled Email": 30, - "Reminder": 30, -} - @runtime_checkable class LogType(Protocol): @@ -81,12 +67,14 @@ class LogSettings(Document): def add_default_logtypes(self): existing_logtypes = {d.ref_doctype for d in self.logs_to_clear} added_logtypes = set() - for logtype, retention in DEFAULT_LOGTYPES_RETENTION.items(): + default_logtypes_retention = frappe.get_hooks("default_log_clearing_doctypes", {}) + + for logtype, retentions in default_logtypes_retention.items(): if logtype not in existing_logtypes and _supports_log_clearing(logtype): if not frappe.db.exists("DocType", logtype): continue - self.append("logs_to_clear", {"ref_doctype": logtype, "days": cint(retention)}) + self.append("logs_to_clear", {"ref_doctype": logtype, "days": cint(retentions[-1])}) added_logtypes.add(logtype) if added_logtypes: diff --git a/frappe/hooks.py b/frappe/hooks.py index e134a2a660..373f21b437 100644 --- a/frappe/hooks.py +++ b/frappe/hooks.py @@ -439,3 +439,18 @@ extend_bootinfo = [ ] export_python_type_annotations = True + +# log doctype cleanups to automatically add in log settings +default_log_clearing_doctypes = { + "Error Log": 30, + "Activity Log": 90, + "Email Queue": 30, + "Scheduled Job Log": 90, + "Route History": 90, + "Submission Queue": 30, + "Prepared Report": 30, + "Webhook Request Log": 30, + "Integration Request": 90, + "Unhandled Email": 30, + "Reminder": 30, +} diff --git a/frappe/utils/boilerplate.py b/frappe/utils/boilerplate.py index 8b87c0ac79..80edc67a0f 100644 --- a/frappe/utils/boilerplate.py +++ b/frappe/utils/boilerplate.py @@ -551,6 +551,14 @@ app_license = "{app_license}" # auth_hooks = [ # "{app_name}.auth.validate" # ] + +# Automatically update python controller files with type annotations for this app. +# export_python_type_annotations = True + +# default_log_clearing_doctypes = {{ +# "Logging DocType Name": 30 # days to retain logs +# }} + """ gitignore_template = """.DS_Store