我想在客户端IP地址添加到日志文件,我曾经想过延长记录器,但不知道如何访问请求对象,并把IP为记录对象
from logging.handlers import RotatingFileHandler
class RequestRotatingFileLogger(RotatingFileHandler, object):
def emit(self, record):
"""
code to manipulate the record to add an attribute to have client IP
record.ip = '123.123.123.123'
"""
super(RequestRotatingFileLogger,self).emit(record)