logging/limit_content: new option
This commit is contained in:
@@ -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)_
|
||||
|
||||
3
config
3
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
|
||||
|
||||
|
||||
@@ -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'",
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user