chore: Clean up and refactor codebase for improved maintainability
- Removed obsolete command-line test parameters from `run_cli.py` to streamline functionality. - Introduced a new `ocr_preprocess.py` module for unified OCR image preprocessing, enhancing recognition stability. - Updated various components to utilize the new preprocessing function, improving code organization and readability. - Adjusted configuration values in `config.json` for better performance and consistency. - Added comprehensive technical documentation for the Douyin project, detailing code modification standards and operational guidelines. - Cleaned up excessive blank lines across multiple files to enhance overall readability.
This commit is contained in:
1 parent
efe6e2252f
commit
223c127e11
70 files changed
+17121
-1752
No files matched your search
@@ -30,6 +30,10 @@ class ErrorLogger:
|
||||
def log_exception(self, exc: BaseException, context: Optional[Dict[str, Any]] = None, level: str = "ERROR") -> None:
|
||||
if not logger:
|
||||
_init_logger()
|
||||
if logger is None:
|
||||
# 如果仍然无法初始化 logger,则退回到标准输出,避免抛出异常
|
||||
print(f"[ErrorLogger] {type(exc).__name__}: {exc}")
|
||||
return
|
||||
tb = traceback.format_exc()
|
||||
ctx = ", ".join(f"{k}={v}" for k, v in (context or {}).items()) if context else ""
|
||||
msg = f"Exception: {type(exc).__name__}: {exc}"
|
||||
@@ -41,6 +45,9 @@ class ErrorLogger:
|
||||
def log_error(self, msg: str, context: Optional[Dict[str, Any]] = None, level: str = "ERROR") -> None:
|
||||
if not logger:
|
||||
_init_logger()
|
||||
if logger is None:
|
||||
print(f"[ErrorLogger] {msg}")
|
||||
return
|
||||
full = msg
|
||||
if context:
|
||||
full += " | " + ", ".join(f"{k}={v}" for k, v in context.items())
|
||||
@@ -54,4 +61,23 @@ class ErrorLogger:
|
||||
|
||||
__all__ = ["ErrorLogger"]
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user