Spaces:
Sleeping
Sleeping
File size: 858 Bytes
07c6a04 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
import logging
import torch.distributed as dist
from rich.logging import RichHandler
def create_logger():
"""
Create a logger that writes to a log file and stdout.
"""
logger = logging.getLogger(__name__)
return logger
def init_dist_logger():
"""
Update the logger to write to a log file.
"""
global logger
if dist.get_rank() == 0:
logger = logging.getLogger(__name__)
handler = RichHandler(show_path=False, markup=True, rich_tracebacks=True)
formatter = logging.Formatter("VideoSys - %(levelname)s: %(message)s")
handler.setFormatter(formatter)
logger.addHandler(handler)
logger.setLevel(logging.INFO)
else: # dummy logger (does nothing)
logger = logging.getLogger(__name__)
logger.addHandler(logging.NullHandler())
logger = create_logger()
|