MCPcopy Index your code
hub / github.com/CodeClash-ai/CodeClash / add_file_handler

Function add_file_handler

codeclash/utils/log.py:68–86  ·  view source on GitHub ↗

Add a file handler to the logger with standard formatting. Returns: The FileHandler that was added (for later cleanup).

(logger: logging.Logger, log_path: Path)

Source from the content-addressed store, hash-verified

66
67
68def add_file_handler(logger: logging.Logger, log_path: Path) -> logging.FileHandler:
69 """Add a file handler to the logger with standard formatting.
70
71 Returns:
72 The FileHandler that was added (for later cleanup).
73 """
74 log_path.parent.mkdir(parents=True, exist_ok=True)
75 file_handler = logging.FileHandler(log_path)
76 file_handler.setLevel(_FILE_LEVEL)
77
78 # Use a standard formatter for file logs with time, name, and level
79 file_formatter = logging.Formatter(
80 fmt="%(asctime)s [%(name)s] %(levelname)s %(message)s",
81 datefmt="%Y-%m-%d %H:%M:%S",
82 )
83 file_handler.setFormatter(file_formatter)
84
85 logger.addHandler(file_handler)
86 return file_handler
87
88
89def add_root_file_handler(log_path: Path) -> logging.FileHandler:

Callers 3

elo.pyFile · 0.90
add_root_file_handlerFunction · 0.85
get_loggerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected