From 3cad0491096dc7f4adc3cb6a0993709966a231be Mon Sep 17 00:00:00 2001 From: Peter Bieringer Date: Sat, 14 Mar 2026 15:12:15 +0100 Subject: [PATCH] logging/limit_content: new option --- DOCUMENTATION.md | 8 ++++++++ config | 3 +++ radicale/config.py | 6 +++++- radicale/utils.py | 6 +++++- 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/DOCUMENTATION.md b/DOCUMENTATION.md index 9e910026..d1864280 100644 --- a/DOCUMENTATION.md +++ b/DOCUMENTATION.md @@ -1679,6 +1679,14 @@ Available levels are: Default: `warning` _(< 3.2.0)_ / `info` _(>= 3.2.0)_ +##### limit_content + +_(> 3.7.0)_ + +Limit content of wrapped text (chars) + +Default: `3000` + ##### trace_on_debug _(> 3.5.4)_ diff --git a/config b/config index 86363049..399d6d9e 100644 --- a/config +++ b/config @@ -362,6 +362,9 @@ # Value: debug | info | warning | error | critical #level = info +# Limit content of wrapped text (chars) +#limit_content = 3000 + # do not filter debug messages starting with 'TRACE' #trace_on_debug = False diff --git a/radicale/config.py b/radicale/config.py index 76e4fdbd..0d50dc7b 100644 --- a/radicale/config.py +++ b/radicale/config.py @@ -37,7 +37,7 @@ from configparser import RawConfigParser from typing import (Any, Callable, ClassVar, Iterable, List, Optional, Sequence, Tuple, TypeVar, Union) -from radicale import auth, hook, rights, sharing, storage, types, web +from radicale import auth, hook, rights, sharing, storage, types, utils, web from radicale.hook import email from radicale.item import check_and_sanitize_props @@ -614,6 +614,10 @@ This is an automated message. Please do not reply.""", "value": "info", "help": "threshold for the logger", "type": logging_level}), + ("limit_content", { + "value": str(utils.DEFAULT_LIMIT_CONTENT), + "help": "limit content of wrapped text (chars)", + "type": positive_int}), ("trace_on_debug", { "value": "False", "help": "do not filter debug messages starting with 'TRACE'", diff --git a/radicale/utils.py b/radicale/utils.py index 9e59dc7b..d25e08e0 100644 --- a/radicale/utils.py +++ b/radicale/utils.py @@ -66,6 +66,10 @@ UNIT_M: int = (1024 * 1024) UNIT_K: int = (1024) +# Limits +DEFAULT_LIMIT_CONTENT: int = 3000 + + def load_plugin(internal_types: Sequence[str], module_name: str, class_name: str, base_class: Type[_T_co], configuration: "config.Configuration") -> _T_co: @@ -385,7 +389,7 @@ def limit_str(content: str, limit: int) -> str: return content -def textwrap_str(content: str, limit: int = 3000) -> str: +def textwrap_str(content: str, limit: int = DEFAULT_LIMIT_CONTENT) -> str: # TODO: add support for config option and prefix return textwrap.indent(limit_str(content, limit), " ", lambda line: True)