File tree Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -587,13 +587,35 @@ class LoggingContextFilter(logging.Filter):
587587    record. 
588588    """ 
589589
590+     def  __init__ (
591+         self ,
592+         # `request` is here for backwards compatibility since we previously recommended 
593+         # people manually configure `LoggingContextFilter` like the following. 
594+         # 
595+         # ```yaml 
596+         # filters: 
597+         #   context: 
598+         #       (): synapse.logging.context.LoggingContextFilter 
599+         #       request: "" 
600+         # ``` 
601+         # 
602+         # TODO: Since we now configure `LoggingContextFilter` automatically since #8051 
603+         # (2020-08-11), we could consider removing this useless parameter. This would 
604+         # require people to remove their own manual configuration of 
605+         # `LoggingContextFilter` as it would cause `TypeError: Filter.__init__() got an 
606+         # unexpected keyword argument 'request'` -> `ValueError: Unable to configure 
607+         # filter 'context'` 
608+         request : str  =  "" ,
609+     ):
610+         self ._default_request  =  request 
611+ 
590612    def  filter (self , record : logging .LogRecord ) ->  Literal [True ]:
591613        """Add each fields from the logging contexts to the record. 
592614        Returns: 
593615            True to include the record in the log output. 
594616        """ 
595617        context  =  current_context ()
596-         record .request  =  "" 
618+         record .request  =  self . _default_request 
597619        record .server_name  =  "unknown_server_from_no_context" 
598620
599621        # context should never be None, but if it somehow ends up being, then 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments