<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def filter(self, record):
 """If request_id is set in flask.g, add it to log record."""

        if g and hasattr(g, 'request_id'):
            record.request_id = g.request_id
        return True