Ticket #5696: logging-extra-v2.2.patch

File logging-extra-v2.2.patch, 0.8 KB (added by richzeng, 23 months ago)

Meant to replace the original patch to twisted.python.log. Other processes make use of the eventDict, so we can't modify it in place. We need to make a copy of eventDict (in this case 'extraDict'). We also need to filter out the extraDict for certain keys that will make Python's stdlib complain when you try to pass them in with the 'extra' keyword.

  • twisted/python/log.py

     
    531531            return 
    532532        self.logger.log(level, text) 
    533533 
     534        extraDict = eventDict.copy() 
     535        for key in extraDict.keys(): 
     536            if key in ['asctime', 'created', 'filename', 'funcName', 
     537                       'levelname', 'levelno', 'lineno', 'module', 'msecs', 
     538                       'message', 'name', 'pathname', 'process', 'processName', 
     539                       'relativeCreated', 'thread', 'threadName']: 
     540                del extraDict[key] 
     541        self.logger.log(level, text, extra=extraDict) 
     542 
    534543    def start(self): 
    535544        """ 
    536545        Start observing log events.