CoolFace
Apppublic

SubstanceSHIFT/SeedVR2-3B

sourceHugging Faceapache-2.0updated 1y agoView on Hugging Face
0likes
logger.py45 linesDownload Raw Back to common
1# // Copyright (c) 2025 Bytedance Ltd. and/or its affiliates2# //3# // Licensed under the Apache License, Version 2.0 (the "License");4# // you may not use this file except in compliance with the License.5# // You may obtain a copy of the License at6# //7# //     http://www.apache.org/licenses/LICENSE-2.08# //9# // Unless required by applicable law or agreed to in writing, software10# // distributed under the License is distributed on an "AS IS" BASIS,11# // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.12# // See the License for the specific language governing permissions and13# // limitations under the License.14 15"""16Logging utility functions.17"""18 19import logging20import sys21from typing import Optional22 23from common.distributed import get_global_rank, get_local_rank, get_world_size24 25_default_handler = logging.StreamHandler(sys.stdout)26_default_handler.setFormatter(27    logging.Formatter(28        "%(asctime)s "29        + (f"[Rank:{get_global_rank()}]" if get_world_size() > 1 else "")30        + (f"[LocalRank:{get_local_rank()}]" if get_world_size() > 1 else "")31        + "[%(threadName).12s][%(name)s][%(levelname).5s] "32        + "%(message)s"33    )34)35 36 37def get_logger(name: Optional[str] = None) -> logging.Logger:38    """39    Get a logger.40    """41    logger = logging.getLogger(name)42    logger.addHandler(_default_handler)43    logger.setLevel(logging.INFO)44    return logger45