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
评论列表
文章目录