MCPcopy Create free account
hub / github.com/LMCache/LMBenchmark / CustomFormatter

Class CustomFormatter

sharegpt/utils.py:16–36  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14
15
16class CustomFormatter(logging.Formatter):
17
18 grey = "\x1b[1m"
19 green = "\x1b[32;20m"
20 yellow = "\x1b[33;20m"
21 red = "\x1b[31;20m"
22 bold_red = "\x1b[31;1m"
23 reset = "\x1b[0m"
24
25 FORMATS = {
26 logging.DEBUG: build_format(grey),
27 logging.INFO: build_format(green),
28 logging.WARNING: build_format(yellow),
29 logging.ERROR: build_format(red),
30 logging.CRITICAL: build_format(bold_red),
31 }
32
33 def format(self, record):
34 log_fmt = self.FORMATS.get(record.levelno)
35 formatter = logging.Formatter(log_fmt)
36 return formatter.format(record)
37
38
39def init_logger(name: str, log_level=logging.DEBUG) -> Logger:

Callers 1

init_loggerFunction · 0.70

Calls 1

build_formatFunction · 0.70

Tested by

no test coverage detected