MCPcopy
hub / github.com/ModelTC/LightLLM / _setup_logger

Function _setup_logger

lightllm/utils/log_utils.py:38–64  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

36
37
38def _setup_logger():
39 _root_logger.setLevel(_LOG_LEVEL)
40 global _default_handler
41 global _default_file_handler
42 fmt = NewLineFormatter(_FORMAT, datefmt=_DATE_FORMAT)
43
44 if _default_handler is None:
45 _default_handler = logging.StreamHandler(sys.stdout)
46 _default_handler.flush = sys.stdout.flush # type: ignore
47 _default_handler.setLevel(_LOG_LEVEL)
48 _root_logger.addHandler(_default_handler)
49
50 if _default_file_handler is None and _LOG_DIR is not None:
51 if not os.path.exists(_LOG_DIR):
52 try:
53 os.makedirs(_LOG_DIR)
54 except OSError as e:
55 _root_logger.warn(f"Error creating directory {_LOG_DIR} : {e}")
56 _default_file_handler = logging.FileHandler(_LOG_DIR + "/default.log")
57 _default_file_handler.setLevel(_LOG_LEVEL)
58 _default_file_handler.setFormatter(fmt)
59 _root_logger.addHandler(_default_file_handler)
60
61 _default_handler.setFormatter(fmt)
62 # Setting this will avoid the message
63 # being propagated to the parent logger.
64 _root_logger.propagate = False
65
66
67# The logger is initialized when the module is imported.

Callers 1

log_utils.pyFile · 0.85

Calls 2

NewLineFormatterClass · 0.85
existsMethod · 0.80

Tested by

no test coverage detected