MCPcopy
hub / github.com/modelscope/FunASR / get_logger

Function get_logger

runtime/python/libtorch/funasr_torch/utils/utils.py:133–161  ·  view source on GitHub ↗

Initialize and get a logger by name. If the logger has not been initialized, this method will initialize the logger by adding one or two handlers, otherwise the initialized logger will be directly returned. During initialization, a StreamHandler will always be added. Args:

(name="funasr_torch")

Source from the content-addressed store, hash-verified

131
132@functools.lru_cache()
133def get_logger(name="funasr_torch"):
134 """Initialize and get a logger by name.
135 If the logger has not been initialized, this method will initialize the
136 logger by adding one or two handlers, otherwise the initialized logger will
137 be directly returned. During initialization, a StreamHandler will always be
138 added.
139 Args:
140 name (str): Logger name.
141 Returns:
142 logging.Logger: The expected logger.
143 """
144 logger = logging.getLogger(name)
145 if name in logger_initialized:
146 return logger
147
148 for logger_name in logger_initialized:
149 if name.startswith(logger_name):
150 return logger
151
152 formatter = logging.Formatter(
153 "[%(asctime)s] %(name)s %(levelname)s: %(message)s", datefmt="%Y/%m/%d %H:%M:%S"
154 )
155
156 sh = logging.StreamHandler()
157 sh.setFormatter(formatter)
158 logger.addHandler(sh)
159 logger_initialized[name] = True
160 logger.propagate = False
161 return logger

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…