MCPcopy Create free account
hub / github.com/InternRobotics/G2VLM / create_logger

Function create_logger

train/train_utils.py:5–23  ·  view source on GitHub ↗

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

(logging_dir, rank, filename="log")

Source from the content-addressed store, hash-verified

3
4
5def create_logger(logging_dir, rank, filename="log"):
6 """
7 Create a logger that writes to a log file and stdout.
8 """
9 if rank == 0 and logging_dir is not None: # real logger
10 logging.basicConfig(
11 level=logging.INFO,
12 format='[\033[34m%(asctime)s\033[0m] %(message)s',
13 datefmt='%Y-%m-%d %H:%M:%S',
14 handlers=[
15 logging.StreamHandler(),
16 logging.FileHandler(f"{logging_dir}/{filename}.txt")
17 ]
18 )
19 logger = logging.getLogger(__name__)
20 else: # dummy logger (does nothing)
21 logger = logging.getLogger(__name__)
22 logger.addHandler(logging.NullHandler())
23 return logger
24
25
26def get_latest_ckpt(checkpoint_dir):

Callers 2

mainFunction · 0.90
mainFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected