MCPcopy Create free account
hub / github.com/FSoft-AI4Code/HyperAgent / setup_logger

Function setup_logger

src/hyperagent/utils.py:437–470  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

435 return f"Error in reading file {file_path}"
436
437def setup_logger():
438 class CustomFormatter(logging.Formatter):
439
440 grey = "\x1b[38;20m"
441 yellow = "\x1b[33;20m"
442 red = "\x1b[31;20m"
443 bold_red = "\x1b[31;1m"
444 reset = "\x1b[0m"
445 format = "%(asctime)s - %(name)s - %(levelname)s - %(message)s (%(filename)s:%(lineno)d)"
446
447 FORMATS = {
448 logging.DEBUG: grey + format + reset,
449 logging.INFO: grey + format + reset,
450 logging.WARNING: yellow + format + reset,
451 logging.ERROR: red + format + reset,
452 logging.CRITICAL: bold_red + format + reset
453 }
454
455 def format(self, record):
456 log_fmt = self.FORMATS.get(record.levelno)
457 formatter = logging.Formatter(log_fmt)
458 return formatter.format(record)
459
460 logging.getLogger("httpx").setLevel(logging.WARNING)
461 logging.getLogger("multilspy").setLevel(logging.FATAL)
462 logger = logging.getLogger("HyperAgent")
463 logger.setLevel(logging.DEBUG)
464 ch = logging.StreamHandler()
465 ch.setLevel(logging.DEBUG)
466
467 ch.setFormatter(CustomFormatter())
468
469 logger.addHandler(ch)
470 return logger
471
472_TEXT_COLOR_MAPPING = {
473 "blue": "36;1",

Callers 1

pilot.pyFile · 0.90

Calls 1

CustomFormatterClass · 0.85

Tested by

no test coverage detected