logging_util.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:schematizer 作者: Yelp 项目源码 文件源码
def initialize_uwsgi_logging(log_name, log_directory, log_suffix):
    """Initialize a logger for the `uwsgi` log, sending output to a rotated
    file on disk. This is used to log errors in service startup.

    :param log_name: The name of the log file
    :param log_directory: The location on disk to write the file to
    :param log_suffix: The suffix to be appended to the log_name. This is
        useful for doing things like differentiating different users
        running the same service.
    """
    global uwsgi_initialized
    if not uwsgi_initialized:
        logger = logging.getLogger('uwsgi')

        complete_log_name = '{0}{1}'.format(log_name, log_suffix)
        path = os.path.join(log_directory, complete_log_name)
        handler = RotatingFileHandler(path, maxBytes=102400, backupCount=3)

        handler.setLevel(logging.INFO)
        handler.setFormatter(logging.Formatter(DETAILED_FORMAT))
        logger.addHandler(handler)
        uwsgi_initialized = True
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号