Log format unification

This commit is contained in:
Flowseal committed 2026-10-31 09:37:41 +03:00
1 parent 19cdbd9d6f
commit 86191badf4
5 files changed
+10 -9

No files matched your search

+2 -2
View File
@@ -5,7 +5,7 @@ import urllib.request as request
url = os.environ["LOG_URL"]
path_answer = ".github/scripts/answers"
for index in range(0,3):
for _ in range(0,3):
try:
with request.urlopen(url,timeout=30.0) as r:
log_bytes = r.read()
@@ -62,4 +62,4 @@ else:
if cfproxy_end is True:
print(str(path_answer + "/default.md"))
else:
print(str(path_answer + "/no_cfproxy.md"))
print(str(path_answer + "/no_cfproxy.md"))
+1 -2
View File
@@ -34,7 +34,6 @@ jobs:
python-version: "3.14"
- name: Clone folder
if: steps.log.outputs.found == 'true'
uses: actions/checkout@v4
with:
sparse-checkout: |
@@ -57,4 +56,4 @@ jobs:
uses: peter-evans/create-or-update-comment@v5
with:
issue-number: ${{ github.event.issue.number }}
body-path: ${{ steps.log.outputs.found == 'true' && steps.comment.outputs.com || '.github/scripts/answers/default.md' }}
body-path: ${{ steps.log.outputs.found == 'true' && steps.comment.outputs.com || '.github/scripts/answers/default.md' }}
-1
View File
@@ -695,7 +695,6 @@ def main():
log_max_mb=args.log_max_mb,
backups=args.log_backups,
)
fh.setFormatter(log_fmt)
fh.addFilter(DomainCensorFilter())
root.addHandler(fh)
+7 -2
View File
@@ -1,4 +1,4 @@
"""Shared construction of the rotating log file handler.
"""Shared construction and formatting of the rotating log file handler.
Centralizes the rotation invariant so both the tray and the CLI log paths
behave identically and the file can never grow without bound (issue #885).
@@ -31,9 +31,14 @@ def build_log_handler(
"""
max_bytes = max(_MIN_BYTES, int(log_max_mb * 1024 * 1024))
backup_count = max(_MIN_BACKUPS, int(backups))
return logging.handlers.RotatingFileHandler(
handler = logging.handlers.RotatingFileHandler(
path,
maxBytes=max_bytes,
backupCount=backup_count,
encoding="utf-8",
)
handler.setFormatter(logging.Formatter(
"%(asctime)s %(levelname)-5s %(name)s %(message)s",
datefmt="%Y-%m-%d %H:%M:%S",
))
return handler
-2
View File
@@ -225,7 +225,6 @@ def save_config(cfg: dict) -> None:
# logging
_LOG_FMT_FILE = "%(asctime)s %(levelname)-5s %(name)s %(message)s"
_LOG_FMT_CONSOLE = "%(asctime)s %(levelname)-5s %(message)s"
@@ -238,7 +237,6 @@ def setup_logging(verbose: bool = False, log_max_mb: float = 5) -> None:
fh = build_log_handler(str(LOG_FILE), log_max_mb=log_max_mb, backups=1)
fh.setLevel(logging.DEBUG)
fh.setFormatter(logging.Formatter(_LOG_FMT_FILE, datefmt="%Y-%m-%d %H:%M:%S"))
fh.addFilter(DomainCensorFilter())
root.addHandler(fh)