title: How to get the actual object passed to a logging call from a logging.Handler
body: <p>Suppose I do the following:</p>
  
  <pre><code>import logging
  
  some_obj = MyObject()
  logging.info(some_obj)
  </code></pre>
  
  <p>and I have a <code>logging.Handler</code> that handles this message:</p>
  
  <pre><code>class MyHandler(logging.Handler):
  
      def emit(self, record):
           # ...
  </code></pre>
  
  <p>Is there a way to get a reference to <code>some_obj</code> from my handler? From the documentation for <a href="https://docs.python.org/3/library/logging.html#logging.LogRecord" rel="nofollow noreferrer"><code>logging.LogRecord</code></a>, it would appear I can only get the string representation of the log invocation (i.e. the first argument merged with any formatting arguments to follow) through <code>record.getMessage()</code>.</p>
  
  <p>I'd like to do this so I can use properties/methods of the object to more cleanly handle logic in the handler. Otherwise I have to base my handler logic on the contents of the string which will end up getting ugly very fast for this particular use case. </p>
  
  <p>Please let me know if there is any additional context required to answer this question. Thanks in advance.</p>