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

Function get_logger

codeclash/utils/log.py:105–129  ·  view source on GitHub ↗

Get logger. Use this instead of `logging.getLogger` to ensure that the logger is set up with the correct handlers.

(name: str, *, emoji: str = "", log_path: Path | None = None)

Source from the content-addressed store, hash-verified

103
104
105def get_logger(name: str, *, emoji: str = "", log_path: Path | None = None) -> logging.Logger:
106 """Get logger. Use this instead of `logging.getLogger` to ensure
107 that the logger is set up with the correct handlers.
108 """
109 logger = logging.getLogger(name)
110 if logger.handlers:
111 # Already set up
112 return logger
113
114 console = Console()
115 handler = logging.StreamHandler()
116 formatter = RichFormatter(console, emoji=emoji)
117
118 handler.setFormatter(formatter)
119 handler.setLevel(_STREAM_LEVEL)
120
121 # Set to lowest level and only use stream handlers to adjust levels
122 logger.setLevel(1)
123 logger.addHandler(handler)
124 logger.propagate = True
125
126 if log_path is not None:
127 add_file_handler(logger, log_path)
128
129 return logger

Callers 15

__init__Method · 0.90
get_environmentMethod · 0.90
ladder.pyFile · 0.90
__init__Method · 0.90
elo.pyFile · 0.90
big_questions.pyFile · 0.90
hallucination.pyFile · 0.90

Calls 2

RichFormatterClass · 0.85
add_file_handlerFunction · 0.85

Tested by

no test coverage detected