def configure_logger(log_dir, is_ps, rank):
    logger = logging.getLogger('')
    logger.setLevel(logging.DEBUG)
    formatter = logging.Formatter('{:6} rank={} : %(message)s'.format(('ps' if is_ps else 'worker'), rank), '%Y-%m-%d %H:%M:%S')
    ch = logging.StreamHandler()
    ch.setLevel(logging.DEBUG)
    ch.setFormatter(formatter)
    logger.addHandler(ch)
    log_name = '{}-{}.log'.format(('ps' if is_ps else 'worker'), rank)
    log_name = os.path.join(log_dir, log_name)
    if os.path.exists(log_name):
        os.remove(log_name)
    fh = logging.FileHandler(log_name)
    fh.setLevel(logging.DEBUG)
    fh.setFormatter(formatter)
    logger.addHandler(fh)
def configure_logger(log_dir, is_ps, rank):
    logger = logging.getLogger()
    logger.setLevel(logging.DEBUG)
    formatter = logging.Formatter('{:6} rank={} : %(message)s'.format(('ps' if is_ps else 'worker'), rank), '%Y-%m-%d %H:%M:%S')
    ch = logging.StreamHandler()
    ch.setLevel(logging.DEBUG)
    ch.setFormatter(formatter)
    logger.addHandler(ch)
    log_name = '{}-{}.log'.format(('ps' if is_ps else 'worker'), rank)
    log_name = os.path.join(log_dir, log_name)
    if os.path.exists(log_name):
        os.remove(log_name)
    fh = logging.FileHandler(log_name)
    fh.setLevel(logging.DEBUG)
    fh.setFormatter(formatter)
    logger.addHandler(fh)