<s> import logging <EOL> from peavy . middleware import RequestLoggingMiddleware <EOL> class BasicFilter ( logging . Filter ) : <EOL> """<STR_LIT>""" <EOL> def filter ( self , record ) : <EOL> request = RequestLoggingMiddleware . context . request <EOL> record . uuid = getattr ( request , "<STR_LIT>" , "<STR_LIT:?>" ) <EOL> if hasattr ( request , "<STR_LIT:user>" ) : <EOL> record . user_pk = getattr ( request . user , '<STR_LIT>' , None ) <EOL> record . username = request . user . username <EOL> else : <EOL> record . user_pk = None <EOL> record . username = "<STR_LIT:?>" <EOL> meta = getattr ( request , "<STR_LIT>" , { } ) <EOL> record . client_ip = meta . get ( "<STR_LIT>" , "<STR_LIT:?>" ) <EOL> return True <EOL> class MetaFilter ( logging . Filter ) : <EOL> """<STR_LIT>""" <EOL> def filter ( self , record ) : <EOL> request = RequestLoggingMiddleware . context . request <EOL> meta = getattr ( request , "<STR_LIT>" , { } ) <EOL> for key , value in meta . items ( ) : <EOL> if hasattr ( record , key ) : <EOL> continue <EOL> setattr ( record , "<STR_LIT>" + key , value ) <EOL> return True <EOL> class RequestIDFilter ( logging . Filter ) : <EOL> """<STR_LIT>""" <EOL> def filter ( self , record ) : <EOL> request = RequestLoggingMiddleware . context . request <EOL> record . uuid = getattr ( request , "<STR_LIT>" , "<STR_LIT:?>" ) <EOL> meta = getattr ( request , "<STR_LIT>" , { } ) <EOL> record . client_ip = meta . get ( "<STR_LIT>" , "<STR_LIT:?>" ) <EOL> return True </s>
