code: def set_context(context):
      
      try:
          handler = logging.getLogger().handlers[0]
      except IndexError:
          # logging is not initialized
          return
      if not isinstance(handler, StructuredHandler):
          return
      handler.acquire()
      try:
          handler.local.context = context
      finally:
          handler.release()
docs: Assign the logging context - an abstract object - to the current thread.