code: def to_dict(self, labels=None):
          
          output = {}
          if labels is None:
              labels = ['line_str', 'split_tokens', 'datetime', 'operation',
                        'thread', 'namespace', 'nscanned', 'ntoreturn',
                        'nreturned', 'ninserted', 'nupdated', 'ndeleted',
                        'duration', 'r', 'w', 'numYields']
  
          for label in labels:
              value = getattr(self, label, None)
              if value is not None:
                  output[label] = value
  
          return output
docs: Convert LogEvent object to a dictionary.