📜  记录器格式 - 任何代码示例

📅  最后修改于: 2022-03-11 14:56:45.551000             🧑  作者: Mango

代码示例4
import logging

def get_logger(log_file_name, log_sub_dir=""):
    """ Creates a Log File and returns Logger object """
    
    # Build Log File Full Path
    logPath = log_file_name if os.path.exists(log_file_name) else os.path.join(log_dir, (str(log_file_name) + '.log'))

    # Create logger object and set the format for logging and other attributes
    logger = logging.Logger(log_file_name)

    # Return logger object
    return logger