mirror of
https://github.com/Flowseal/tg-ws-proxy.git
synced 2026-11-01 02:06:58 +03:00
Log format unification
This commit is contained in:
1 parent
19cdbd9d6f
commit
86191badf4
5 files changed
+10
-9
No files matched your search
@@ -5,7 +5,7 @@ import urllib.request as request
|
|||||||
url = os.environ["LOG_URL"]
|
url = os.environ["LOG_URL"]
|
||||||
path_answer = ".github/scripts/answers"
|
path_answer = ".github/scripts/answers"
|
||||||
|
|
||||||
for index in range(0,3):
|
for _ in range(0,3):
|
||||||
try:
|
try:
|
||||||
with request.urlopen(url,timeout=30.0) as r:
|
with request.urlopen(url,timeout=30.0) as r:
|
||||||
log_bytes = r.read()
|
log_bytes = r.read()
|
||||||
@@ -62,4 +62,4 @@ else:
|
|||||||
if cfproxy_end is True:
|
if cfproxy_end is True:
|
||||||
print(str(path_answer + "/default.md"))
|
print(str(path_answer + "/default.md"))
|
||||||
else:
|
else:
|
||||||
print(str(path_answer + "/no_cfproxy.md"))
|
print(str(path_answer + "/no_cfproxy.md"))
|
||||||
@@ -34,7 +34,6 @@ jobs:
|
|||||||
python-version: "3.14"
|
python-version: "3.14"
|
||||||
|
|
||||||
- name: Clone folder
|
- name: Clone folder
|
||||||
if: steps.log.outputs.found == 'true'
|
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
sparse-checkout: |
|
sparse-checkout: |
|
||||||
@@ -57,4 +56,4 @@ jobs:
|
|||||||
uses: peter-evans/create-or-update-comment@v5
|
uses: peter-evans/create-or-update-comment@v5
|
||||||
with:
|
with:
|
||||||
issue-number: ${{ github.event.issue.number }}
|
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' }}
|
||||||
@@ -695,7 +695,6 @@ def main():
|
|||||||
log_max_mb=args.log_max_mb,
|
log_max_mb=args.log_max_mb,
|
||||||
backups=args.log_backups,
|
backups=args.log_backups,
|
||||||
)
|
)
|
||||||
fh.setFormatter(log_fmt)
|
|
||||||
fh.addFilter(DomainCensorFilter())
|
fh.addFilter(DomainCensorFilter())
|
||||||
root.addHandler(fh)
|
root.addHandler(fh)
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
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).
|
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))
|
max_bytes = max(_MIN_BYTES, int(log_max_mb * 1024 * 1024))
|
||||||
backup_count = max(_MIN_BACKUPS, int(backups))
|
backup_count = max(_MIN_BACKUPS, int(backups))
|
||||||
return logging.handlers.RotatingFileHandler(
|
handler = logging.handlers.RotatingFileHandler(
|
||||||
path,
|
path,
|
||||||
maxBytes=max_bytes,
|
maxBytes=max_bytes,
|
||||||
backupCount=backup_count,
|
backupCount=backup_count,
|
||||||
encoding="utf-8",
|
encoding="utf-8",
|
||||||
)
|
)
|
||||||
|
handler.setFormatter(logging.Formatter(
|
||||||
|
"%(asctime)s %(levelname)-5s %(name)s %(message)s",
|
||||||
|
datefmt="%Y-%m-%d %H:%M:%S",
|
||||||
|
))
|
||||||
|
return handler
|
||||||
@@ -225,7 +225,6 @@ def save_config(cfg: dict) -> None:
|
|||||||
|
|
||||||
# logging
|
# logging
|
||||||
|
|
||||||
_LOG_FMT_FILE = "%(asctime)s %(levelname)-5s %(name)s %(message)s"
|
|
||||||
_LOG_FMT_CONSOLE = "%(asctime)s %(levelname)-5s %(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 = build_log_handler(str(LOG_FILE), log_max_mb=log_max_mb, backups=1)
|
||||||
fh.setLevel(logging.DEBUG)
|
fh.setLevel(logging.DEBUG)
|
||||||
fh.setFormatter(logging.Formatter(_LOG_FMT_FILE, datefmt="%Y-%m-%d %H:%M:%S"))
|
|
||||||
fh.addFilter(DomainCensorFilter())
|
fh.addFilter(DomainCensorFilter())
|
||||||
root.addHandler(fh)
|
root.addHandler(fh)
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user