refactor(cleanup): 移除 logging 模块死代码
- unified_logger.py: 删除 5 个从未使用的装饰器/函数 - internal_loggers.py: 删除 3 个未使用方法和工厂函数 - action_logger.py: 删除 3 个未使用方法 - log_formatter.py: 删除 6 个未使用格式化函数(保留 GUI 依赖的 4 个) - 同步更新 __init__.py 和测试文件 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
703da834fb
commit
d19d5bfc56
8 files changed
+12
-482
No files matched your search
@@ -14,19 +14,17 @@
|
||||
from .log_formatter import (
|
||||
format_debug_log,
|
||||
format_action_log,
|
||||
format_call_stack,
|
||||
format_parameters,
|
||||
format_variables,
|
||||
format_exception,
|
||||
add_separators,
|
||||
format_error_log,
|
||||
add_colors,
|
||||
beautify_log_output,
|
||||
colorize_log_line,
|
||||
)
|
||||
|
||||
# 性能追踪模块
|
||||
from .performance_tracker import PerformanceTracker
|
||||
|
||||
# 错误与调试日志(合并到 internal_loggers)
|
||||
from .internal_loggers import ErrorLogger, DebugLogger, _get_debug_logger
|
||||
from .internal_loggers import ErrorLogger, DebugLogger
|
||||
|
||||
# 行为日志模块(含 track_action 装饰器)
|
||||
from .action_logger import ActionLogger, track_action
|
||||
@@ -38,12 +36,10 @@ __all__ = [
|
||||
# 格式化函数
|
||||
"format_debug_log",
|
||||
"format_action_log",
|
||||
"format_call_stack",
|
||||
"format_parameters",
|
||||
"format_variables",
|
||||
"format_exception",
|
||||
"add_separators",
|
||||
"format_error_log",
|
||||
"add_colors",
|
||||
"beautify_log_output",
|
||||
"colorize_log_line",
|
||||
# 类
|
||||
"PerformanceTracker",
|
||||
"ErrorLogger",
|
||||
@@ -52,5 +48,4 @@ __all__ = [
|
||||
"LoggingWrapper",
|
||||
# 装饰器和工具函数
|
||||
"track_action",
|
||||
"_get_debug_logger",
|
||||
]
|
||||
@@ -95,15 +95,6 @@ class ActionLogger:
|
||||
msg = format_action_log(operation, details or "", **extra)
|
||||
_logger.info(msg)
|
||||
|
||||
def log_ocr(self, region: str, result: str, elapsed: Optional[float] = None) -> None:
|
||||
self.log_operation("OCR", f"region={region} result={result}", elapsed=elapsed)
|
||||
|
||||
def log_decision(self, decision: str, elapsed: Optional[float] = None) -> None:
|
||||
self.log_operation("Decision", decision, elapsed=elapsed)
|
||||
|
||||
def log_state_change(self, before: str, after: str, elapsed: Optional[float] = None) -> None:
|
||||
self.log_operation("StateChange", f"{before}->{after}", elapsed=elapsed)
|
||||
|
||||
def log_step(self, name: str, elapsed: Optional[float] = None) -> None:
|
||||
self.log_operation("Step", name, elapsed=elapsed)
|
||||
|
||||
|
||||
@@ -146,32 +146,6 @@ class DebugLogger:
|
||||
def __init__(self, enabled: bool = True) -> None:
|
||||
self.enabled = enabled
|
||||
|
||||
def log_function_entry(
|
||||
self, func_name: str, *args: Any, **kwargs: Any
|
||||
) -> None:
|
||||
if not self.enabled:
|
||||
return
|
||||
line = format_debug_log(
|
||||
f"FunctionEntry: {func_name}",
|
||||
level="DEBUG",
|
||||
args=args,
|
||||
kwargs=kwargs,
|
||||
)
|
||||
_debug_module_logger.debug(line)
|
||||
|
||||
def log_function_exit(
|
||||
self, func_name: str, retval: Any, elapsed: float
|
||||
) -> None:
|
||||
if not self.enabled:
|
||||
return
|
||||
line = format_debug_log(
|
||||
f"FunctionExit: {func_name}",
|
||||
level="DEBUG",
|
||||
elapsed_seconds=elapsed,
|
||||
return_value=retval,
|
||||
)
|
||||
_debug_module_logger.debug(line)
|
||||
|
||||
def log_variable(self, name: str, value: Any) -> None:
|
||||
if not self.enabled:
|
||||
return
|
||||
@@ -180,15 +154,6 @@ class DebugLogger:
|
||||
)
|
||||
_debug_module_logger.debug(line)
|
||||
|
||||
def log_call_stack(self) -> None:
|
||||
if not self.enabled:
|
||||
return
|
||||
stack = traceback.format_stack()
|
||||
line = format_debug_log(
|
||||
"CallStack", level="DEBUG", stack="".join(stack)
|
||||
)
|
||||
_debug_module_logger.debug(line)
|
||||
|
||||
def log_exception(
|
||||
self, exc: BaseException, context: Optional[Dict[str, Any]] = None
|
||||
) -> None:
|
||||
@@ -221,8 +186,4 @@ class DebugLogger:
|
||||
_perf.get_elapsed(name)
|
||||
|
||||
|
||||
def _get_debug_logger() -> DebugLogger:
|
||||
return DebugLogger(True)
|
||||
|
||||
|
||||
__all__ = ["ErrorLogger", "DebugLogger", "_get_debug_logger"]
|
||||
__all__ = ["ErrorLogger", "DebugLogger"]
|
||||
@@ -127,7 +127,6 @@ def format_action_log(action: str, details: Optional[str] = None, **fields: Any)
|
||||
def format_error_log(
|
||||
message: str, level: str = "ERROR", tag: Optional[str] = None, **fields: Any
|
||||
) -> str:
|
||||
"""格式化错误日志"""
|
||||
parts = []
|
||||
if tag:
|
||||
parts.append(f"[{tag}]")
|
||||
@@ -139,39 +138,7 @@ def format_error_log(
|
||||
return " ".join(parts)
|
||||
|
||||
|
||||
def format_call_stack(stack: Optional[List[str]] = None) -> str:
|
||||
if not stack:
|
||||
return ""
|
||||
return "\n".join(stack)
|
||||
|
||||
|
||||
def format_parameters(params: Dict[str, Any]) -> str:
|
||||
if not params:
|
||||
return ""
|
||||
return " ".join(f"{k}={v}" for k, v in params.items())
|
||||
|
||||
|
||||
def format_variables(vars: Dict[str, Any]) -> str:
|
||||
if not vars:
|
||||
return ""
|
||||
return " ".join(f"{k}={v}" for k, v in vars.items())
|
||||
|
||||
|
||||
def format_exception(exc: BaseException) -> str:
|
||||
import traceback
|
||||
|
||||
return "".join(traceback.format_exception(type(exc), exc, exc.__traceback__))
|
||||
|
||||
|
||||
def add_separators(text: str, label: Optional[str] = None) -> str:
|
||||
if not label:
|
||||
label = ""
|
||||
sep = "=" * 80
|
||||
return f"{sep}\n {label} \n{sep}\n{text}\n{sep}"
|
||||
|
||||
|
||||
def add_colors(text: str, color: str = "green") -> str:
|
||||
# 简易颜色支持,只有在控制台启用时有效
|
||||
colors = {
|
||||
"red": "\033[31m",
|
||||
"green": "\033[32m",
|
||||
@@ -185,48 +152,19 @@ def add_colors(text: str, color: str = "green") -> str:
|
||||
|
||||
|
||||
def beautify_log_output(line: str) -> str:
|
||||
"""
|
||||
美化日志输出,为GUI显示优化格式。
|
||||
|
||||
对日志行进行美化处理,包括:
|
||||
- 提取关键信息
|
||||
- 简化冗余部分
|
||||
- 突出重要信息
|
||||
"""
|
||||
if not line or not line.strip():
|
||||
return line
|
||||
|
||||
# 对于GUI显示,我们保持相对简洁但有用的格式
|
||||
# 移除过长的堆栈跟踪,但保留关键错误信息
|
||||
if len(line) > 500:
|
||||
# 如果行太长,进行截断
|
||||
parts = line.split()
|
||||
if len(parts) > 10:
|
||||
# 保留前10个部分和最后的部分
|
||||
shortened = " ".join(parts[:8]) + " ... " + " ".join(parts[-2:])
|
||||
return shortened
|
||||
|
||||
# 突出显示重要关键字
|
||||
important_keywords = ["ERROR", "CRITICAL", "FAILED", "EXCEPTION"]
|
||||
for keyword in important_keywords:
|
||||
if keyword in line.upper():
|
||||
# 在GUI中我们不添加颜色代码,因为GUI使用标签系统
|
||||
# 这里只是为了标识重要行
|
||||
break
|
||||
|
||||
return line
|
||||
|
||||
|
||||
def colorize_log_line(line: str) -> str:
|
||||
"""
|
||||
为日志行添加颜色代码(用于控制台输出)。
|
||||
|
||||
基于日志级别和内容为日志行添加ANSI颜色代码。
|
||||
"""
|
||||
if not line:
|
||||
return line
|
||||
|
||||
# 检查日志级别并应用相应颜色
|
||||
if "[DEBUG]" in line:
|
||||
return add_colors(line, "blue")
|
||||
elif "[INFO]" in line:
|
||||
@@ -236,14 +174,7 @@ def colorize_log_line(line: str) -> str:
|
||||
elif "[ERROR]" in line:
|
||||
return add_colors(line, "red")
|
||||
elif "[CRITICAL]" in line:
|
||||
return add_colors(line, "red") # 红色加粗可以通过多次应用实现
|
||||
|
||||
# 检查特殊内容
|
||||
if "elapsed_seconds=" in line or "耗时" in line:
|
||||
return add_colors(line, "green")
|
||||
if "EXCEPTION" in line.upper():
|
||||
return add_colors(line, "red")
|
||||
|
||||
return line
|
||||
|
||||
|
||||
@@ -251,11 +182,6 @@ __all__ = [
|
||||
"format_debug_log",
|
||||
"format_action_log",
|
||||
"format_error_log",
|
||||
"format_call_stack",
|
||||
"format_parameters",
|
||||
"format_variables",
|
||||
"format_exception",
|
||||
"add_separators",
|
||||
"add_colors",
|
||||
"beautify_log_output",
|
||||
"colorize_log_line",
|
||||
|
||||
@@ -22,7 +22,7 @@ import logging
|
||||
import threading
|
||||
import inspect
|
||||
import traceback
|
||||
from typing import Optional, Dict, Any, Callable
|
||||
from typing import Optional, Dict, Any
|
||||
from functools import wraps
|
||||
from contextlib import contextmanager
|
||||
|
||||
@@ -356,174 +356,6 @@ def get_unified_logger(name: Optional[str] = None) -> logging.Logger:
|
||||
return logger
|
||||
|
||||
|
||||
@contextmanager
|
||||
def trace_context(trace_id: Optional[str] = None, **mdc_context):
|
||||
"""上下文管理器:为代码块设置traceId和MDC上下文"""
|
||||
old_trace_id = MDC.get_trace_id()
|
||||
old_mdc = MDC.get_all()
|
||||
|
||||
# 设置新的traceId
|
||||
if trace_id is None:
|
||||
trace_id = MDC.set_trace_id()
|
||||
else:
|
||||
MDC.set_trace_id(trace_id)
|
||||
|
||||
# 设置其他MDC上下文
|
||||
for key, value in mdc_context.items():
|
||||
MDC.put(key, value)
|
||||
|
||||
try:
|
||||
yield trace_id
|
||||
finally:
|
||||
# 恢复旧的MDC
|
||||
MDC.clear()
|
||||
if old_trace_id:
|
||||
MDC.set_trace_id(old_trace_id)
|
||||
for key, value in old_mdc.items():
|
||||
MDC.put(key, value)
|
||||
|
||||
|
||||
def log_method_entry_exit(
|
||||
logger: Optional[logging.Logger] = None,
|
||||
log_args: bool = True,
|
||||
log_result: bool = False,
|
||||
log_duration: bool = True,
|
||||
min_duration: float = 0.0,
|
||||
):
|
||||
"""装饰器:自动记录方法入口、出口、参数、返回值、耗时"""
|
||||
|
||||
def decorator(func: Callable) -> Callable:
|
||||
@wraps(func)
|
||||
def wrapper(*args, **kwargs):
|
||||
if logger is None:
|
||||
_logger = get_unified_logger()
|
||||
else:
|
||||
_logger = logger
|
||||
|
||||
func_name = f"{func.__module__}.{func.__name__}"
|
||||
start_time = time.time()
|
||||
|
||||
# 记录方法入口
|
||||
if log_args:
|
||||
args_str = ", ".join([str(arg)[:100] for arg in args[:3]])
|
||||
kwargs_str = ", ".join(
|
||||
[f"{k}={str(v)[:50]}" for k, v in list(kwargs.items())[:3]]
|
||||
)
|
||||
call_info = (
|
||||
f"{func_name}({args_str}{', ' + kwargs_str if kwargs_str else ''})"
|
||||
)
|
||||
if len(args) > 3 or len(kwargs) > 3:
|
||||
call_info += "..."
|
||||
_logger.info(f"[方法入口] {call_info}")
|
||||
|
||||
# 执行方法
|
||||
try:
|
||||
result = func(*args, **kwargs)
|
||||
elapsed = time.time() - start_time
|
||||
|
||||
# 记录方法出口
|
||||
exit_msg = f"[方法出口] {func_name}"
|
||||
if log_duration and elapsed >= min_duration:
|
||||
exit_msg += f" 耗时: {elapsed:.3f}秒"
|
||||
if log_result:
|
||||
result_str = str(result)[:200]
|
||||
exit_msg += f" 返回值: {result_str}"
|
||||
|
||||
_logger.info(exit_msg)
|
||||
|
||||
return result
|
||||
except Exception as e:
|
||||
elapsed = time.time() - start_time
|
||||
_logger.error(
|
||||
f"[方法异常] {func_name} 发生异常: {type(e).__name__}: {str(e)} "
|
||||
f"耗时: {elapsed:.3f}秒",
|
||||
exc_info=True,
|
||||
)
|
||||
raise
|
||||
|
||||
return wrapper
|
||||
|
||||
return decorator
|
||||
|
||||
|
||||
def log_external_call(
|
||||
target: str,
|
||||
request_params: Optional[Dict[str, Any]] = None,
|
||||
response_result: Optional[Any] = None,
|
||||
success: bool = True,
|
||||
duration: Optional[float] = None,
|
||||
logger: Optional[logging.Logger] = None,
|
||||
):
|
||||
"""记录外部调用(API调用、数据库查询等)"""
|
||||
if logger is None:
|
||||
logger = get_unified_logger()
|
||||
|
||||
# 脱敏请求参数
|
||||
if request_params:
|
||||
request_params = SensitiveDataMasker.mask_dict(request_params)
|
||||
|
||||
msg_parts = [f"[外部调用] {target}"]
|
||||
|
||||
if request_params:
|
||||
params_str = ", ".join(
|
||||
[f"{k}={v}" for k, v in list(request_params.items())[:5]]
|
||||
)
|
||||
if len(request_params) > 5:
|
||||
params_str += "..."
|
||||
msg_parts.append(f"请求参数: {params_str}")
|
||||
|
||||
if response_result is not None:
|
||||
result_str = str(response_result)[:200]
|
||||
msg_parts.append(f"响应结果: {result_str}")
|
||||
|
||||
if duration is not None:
|
||||
msg_parts.append(f"耗时: {duration:.3f}秒")
|
||||
|
||||
msg_parts.append(f"状态: {'成功' if success else '失败'}")
|
||||
|
||||
level = logging.INFO if success else logging.ERROR
|
||||
logger.log(level, " | ".join(msg_parts))
|
||||
|
||||
|
||||
def log_decision_point(
|
||||
decision: str,
|
||||
condition: Optional[str] = None,
|
||||
result: Any = None,
|
||||
logger: Optional[logging.Logger] = None,
|
||||
):
|
||||
"""记录关键决策点(分支判断、条件判断等)"""
|
||||
if logger is None:
|
||||
logger = get_unified_logger()
|
||||
|
||||
msg_parts = [f"[决策点] {decision}"]
|
||||
|
||||
if condition:
|
||||
msg_parts.append(f"条件: {condition}")
|
||||
|
||||
if result is not None:
|
||||
result_str = str(result)[:100]
|
||||
msg_parts.append(f"结果: {result_str}")
|
||||
|
||||
logger.info(" | ".join(msg_parts))
|
||||
|
||||
|
||||
def log_state_change(
|
||||
old_state: Any,
|
||||
new_state: Any,
|
||||
reason: Optional[str] = None,
|
||||
logger: Optional[logging.Logger] = None,
|
||||
):
|
||||
"""记录状态变化"""
|
||||
if logger is None:
|
||||
logger = get_unified_logger()
|
||||
|
||||
msg_parts = [f"[状态变化] {old_state} -> {new_state}"]
|
||||
|
||||
if reason:
|
||||
msg_parts.append(f"原因: {reason}")
|
||||
|
||||
logger.info(" | ".join(msg_parts))
|
||||
|
||||
|
||||
# 导出主要接口
|
||||
__all__ = [
|
||||
@@ -531,9 +363,4 @@ __all__ = [
|
||||
"SensitiveDataMasker",
|
||||
"UnifiedFormatter",
|
||||
"get_unified_logger",
|
||||
"trace_context",
|
||||
"log_method_entry_exit",
|
||||
"log_external_call",
|
||||
"log_decision_point",
|
||||
"log_state_change",
|
||||
]
|
||||
@@ -32,21 +32,6 @@ class TestActionLoggerMethods:
|
||||
alog.log_operation("click", details="button_x", x=100, y=200)
|
||||
alog.log_operation("simple_op")
|
||||
|
||||
def test_log_decision(self, alog, caplog):
|
||||
with caplog.at_level(logging.INFO):
|
||||
alog.log_decision("参与", elapsed=0.05)
|
||||
alog.log_decision("跳过")
|
||||
|
||||
def test_log_state_change(self, alog, caplog):
|
||||
with caplog.at_level(logging.INFO):
|
||||
alog.log_state_change("recommend", "live_room", elapsed=0.5)
|
||||
alog.log_state_change("A", "B")
|
||||
|
||||
def test_log_ocr(self, alog, caplog):
|
||||
with caplog.at_level(logging.INFO):
|
||||
alog.log_ocr("countdown_region", "00:30", elapsed=0.1)
|
||||
alog.log_ocr("region", "")
|
||||
|
||||
def test_long_kwargs_does_not_raise(self, alog):
|
||||
# 大量 kwargs 不应导致格式化失败
|
||||
alog.log_operation("complex", **{f"k{i}": i for i in range(50)})
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
"""douyin/logging/log_formatter 的 pytest 单元测试。
|
||||
|
||||
覆盖 9 个格式化纯函数:
|
||||
覆盖格式化纯函数:
|
||||
- format_action_log / format_debug_log / format_error_log
|
||||
- format_parameters / format_variables / format_call_stack
|
||||
- format_exception / add_colors / add_separators
|
||||
- add_colors
|
||||
- beautify_log_output / colorize_log_line(一致性 + 不抛断言)
|
||||
"""
|
||||
from __future__ import annotations
|
||||
@@ -67,64 +66,7 @@ class TestFormatErrorLog:
|
||||
|
||||
|
||||
# ============================================================
|
||||
# format_parameters / format_variables
|
||||
# ============================================================
|
||||
|
||||
class TestFormatParametersVariables:
|
||||
def test_format_parameters_with_data(self):
|
||||
result = f.format_parameters({"a": 1, "b": "x"})
|
||||
assert "a=1" in result
|
||||
assert "b=x" in result
|
||||
|
||||
def test_format_parameters_empty(self):
|
||||
assert f.format_parameters({}) == ""
|
||||
|
||||
def test_format_variables_with_data(self):
|
||||
result = f.format_variables({"k": "v"})
|
||||
assert "k=v" in result
|
||||
|
||||
def test_format_variables_empty(self):
|
||||
assert f.format_variables({}) == ""
|
||||
|
||||
|
||||
# ============================================================
|
||||
# format_call_stack
|
||||
# ============================================================
|
||||
|
||||
class TestFormatCallStack:
|
||||
def test_empty(self):
|
||||
assert f.format_call_stack() == ""
|
||||
|
||||
def test_with_frames(self):
|
||||
result = f.format_call_stack(["frame1", "frame2"])
|
||||
assert "frame1" in result
|
||||
assert "frame2" in result
|
||||
|
||||
|
||||
# ============================================================
|
||||
# format_exception
|
||||
# ============================================================
|
||||
|
||||
class TestFormatException:
|
||||
def test_includes_traceback(self):
|
||||
try:
|
||||
raise RuntimeError("boom")
|
||||
except RuntimeError as e:
|
||||
result = f.format_exception(e)
|
||||
assert "RuntimeError" in result
|
||||
assert "boom" in result
|
||||
|
||||
def test_returns_string(self):
|
||||
try:
|
||||
raise ValueError("bad")
|
||||
except ValueError as e:
|
||||
result = f.format_exception(e)
|
||||
assert isinstance(result, str)
|
||||
assert len(result) > 0
|
||||
|
||||
|
||||
# ============================================================
|
||||
# add_colors / add_separators
|
||||
# add_colors
|
||||
# ============================================================
|
||||
|
||||
class TestAddColors:
|
||||
@@ -146,20 +88,6 @@ class TestAddColors:
|
||||
assert "hi" in result
|
||||
|
||||
|
||||
class TestAddSeparators:
|
||||
def test_with_label(self):
|
||||
result = f.add_separators("content", label="SECTION")
|
||||
assert "content" in result
|
||||
assert "SECTION" in result
|
||||
# 包含分隔线
|
||||
assert "=" * 80 in result
|
||||
|
||||
def test_without_label(self):
|
||||
result = f.add_separators("content")
|
||||
assert "content" in result
|
||||
assert "=" * 80 in result
|
||||
|
||||
|
||||
# ============================================================
|
||||
# beautify_log_output / colorize_log_line(一致性 / 不抛)
|
||||
# ============================================================
|
||||
|
||||
@@ -79,89 +79,6 @@ class TestFormatErrorLog:
|
||||
assert len(result) > 0
|
||||
|
||||
|
||||
class TestFormatCallStack:
|
||||
"""format_call_stack 纯函数测试。"""
|
||||
|
||||
def test_empty_stack(self):
|
||||
from douyin.logging.log_formatter import format_call_stack
|
||||
|
||||
result = format_call_stack(None)
|
||||
assert isinstance(result, str)
|
||||
|
||||
def test_with_stack(self):
|
||||
from douyin.logging.log_formatter import format_call_stack
|
||||
|
||||
stack = ["func1", "func2", "func3"]
|
||||
result = format_call_stack(stack)
|
||||
assert isinstance(result, str)
|
||||
|
||||
|
||||
class TestFormatParameters:
|
||||
"""format_parameters 纯函数测试。"""
|
||||
|
||||
def test_empty_params(self):
|
||||
from douyin.logging.log_formatter import format_parameters
|
||||
|
||||
result = format_parameters({})
|
||||
assert isinstance(result, str)
|
||||
|
||||
def test_with_params(self):
|
||||
from douyin.logging.log_formatter import format_parameters
|
||||
|
||||
result = format_parameters({"x": 1, "y": 2})
|
||||
assert isinstance(result, str)
|
||||
|
||||
|
||||
class TestFormatVariables:
|
||||
"""format_variables 纯函数测试。"""
|
||||
|
||||
def test_empty_vars(self):
|
||||
from douyin.logging.log_formatter import format_variables
|
||||
|
||||
result = format_variables({})
|
||||
assert isinstance(result, str)
|
||||
|
||||
def test_with_vars(self):
|
||||
from douyin.logging.log_formatter import format_variables
|
||||
|
||||
result = format_variables({"a": "hello", "b": 123})
|
||||
assert isinstance(result, str)
|
||||
|
||||
|
||||
class TestFormatException:
|
||||
"""format_exception 纯函数测试。"""
|
||||
|
||||
def test_value_error(self):
|
||||
from douyin.logging.log_formatter import format_exception
|
||||
|
||||
exc = ValueError("test error")
|
||||
result = format_exception(exc)
|
||||
assert "ValueError" in result or "test error" in result
|
||||
|
||||
def test_runtime_error(self):
|
||||
from douyin.logging.log_formatter import format_exception
|
||||
|
||||
exc = RuntimeError("runtime issue")
|
||||
result = format_exception(exc)
|
||||
assert isinstance(result, str)
|
||||
|
||||
|
||||
class TestAddSeparators:
|
||||
"""add_separators 纯函数测试。"""
|
||||
|
||||
def test_basic_text(self):
|
||||
from douyin.logging.log_formatter import add_separators
|
||||
|
||||
result = add_separators("test content")
|
||||
assert "test content" in result
|
||||
|
||||
def test_with_label(self):
|
||||
from douyin.logging.log_formatter import add_separators
|
||||
|
||||
result = add_separators("content", label="Section")
|
||||
assert "content" in result
|
||||
|
||||
|
||||
class TestAddColors:
|
||||
"""add_colors 纯函数测试。"""
|
||||
|
||||
|
||||
Reference in new issue
Block a user