MCPcopy Create free account
hub / github.com/Vchitect/SEINE / create_logger

Function create_logger

utils.py:166–183  ·  view source on GitHub ↗

Create a logger that writes to a log file and stdout.

(logging_dir)

Source from the content-addressed store, hash-verified

164#################################################################################
165
166def create_logger(logging_dir):
167 """
168 Create a logger that writes to a log file and stdout.
169 """
170 if dist.get_rank() == 0: # real logger
171 logging.basicConfig(
172 level=logging.INFO,
173 # format='[\033[34m%(asctime)s\033[0m] %(message)s',
174 format='[%(asctime)s] %(message)s',
175 datefmt='%Y-%m-%d %H:%M:%S',
176 handlers=[logging.StreamHandler(), logging.FileHandler(f"{logging_dir}/log.txt")]
177 )
178 logger = logging.getLogger(__name__)
179
180 else: # dummy logger (does nothing)
181 logger = logging.getLogger(__name__)
182 logger.addHandler(logging.NullHandler())
183 return logger
184
185def create_accelerate_logger(logging_dir, is_main_process=False):
186 """

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected