MCPcopy
hub / github.com/FoundationVision/LlamaGen / create_logger

Function create_logger

utils/logger.py:4–19  ·  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

2import torch.distributed as dist
3
4def create_logger(logging_dir):
5 """
6 Create a logger that writes to a log file and stdout.
7 """
8 if dist.get_rank() == 0: # real logger
9 logging.basicConfig(
10 level=logging.INFO,
11 format='[\033[34m%(asctime)s\033[0m] %(message)s',
12 datefmt='%Y-%m-%d %H:%M:%S',
13 handlers=[logging.StreamHandler(), logging.FileHandler(f"{logging_dir}/log.txt")]
14 )
15 logger = logging.getLogger(__name__)
16 else: # dummy logger (does nothing)
17 logger = logging.getLogger(__name__)
18 logger.addHandler(logging.NullHandler())
19 return logger

Callers 4

mainFunction · 0.90
mainFunction · 0.90
mainFunction · 0.90
mainFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected