Adjust: [logging] header/content debug log indended by space to be skipped by logwatch
This commit is contained in:
@@ -21,6 +21,7 @@ import datetime
|
||||
import os
|
||||
import ssl
|
||||
import sys
|
||||
import textwrap
|
||||
from importlib import import_module, metadata
|
||||
from typing import Callable, Sequence, Tuple, Type, TypeVar, Union
|
||||
|
||||
@@ -291,3 +292,16 @@ def format_ut(unixtime: int) -> str:
|
||||
dt = datetime.datetime.fromtimestamp(unixtime, datetime.UTC)
|
||||
r = str(unixtime) + "(" + dt.strftime('%Y-%m-%dT%H:%M:%SZ') + ")"
|
||||
return r
|
||||
|
||||
|
||||
def limit_str(content: str, limit: int) -> str:
|
||||
length = len(content)
|
||||
if limit > 0 and length >= limit:
|
||||
return content[:limit] + ("...(shortened because original length %d > limit %d)" % (length, limit))
|
||||
else:
|
||||
return content
|
||||
|
||||
|
||||
def textwrap_str(content: str, limit: int = 2000) -> 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