title: Custom variable field to python log record
body: <p>I am trying to add a custom format field in my library. I know this is either done with a Filter or a LoggerAdapter object. However, in the examples I have seen (like this one: <a href="https://stackoverflow.com/questions/17558552/how-do-i-add-custom-field-to-python-log-format-string">How do I add custom field to Python log format string?</a>) the custom field they want to generate is static and known when the logger is created.</p>
  
  <p>I need to be able to send a variable to my log record that I really don't know until just before I write the log record. I guess I am just not seeing the solution but how best to accomplish this?</p>
  
  <p>Currently I set up my logger this way:</p>
  
  <pre><code>import logging
  
  class MyClass:
      filehandler = logging.handlers.RotatingRileHandler(r'C:\Users\Me\Desktop\Logs', 
              maxBytes=1000000, backupCount=4, encoding='ASCII')
      formatter = logging.Formatter('[%(asctime)s] : %(levelname)-8s: Para: %(parameter)-15s'
                                    ' - %(message)s')
      # parameter is my custom name I want to inject
      self.logger = logging.getLogger(__name__)
      self.logger.setLevel(logging.DEBUG)
      self.logger.addHandler(file_handler)
  
      d = {'parameter': ''}
      self.logger = logging.LoggerAdapter(self.logger, extra=d)
  </code></pre>
  
  <p>And in my test I write:</p>
  
  <pre><code>my_obj = MyClass()
  my_obj.logger.error('This is my error.', extra={'parameter': 'True'}
  </code></pre>
  
  <p>but this makes the parameter field '' (blank string) always. Is there a way to set up the <code>d</code> dictionary for each time I make the log call (<code>error()</code>, <code>debug()</code>, etc.)?</p>