class_docstr: Utility that aggregates related log messages to reduce log spam.
docstr: Add a log message, which will be combined by template.
  
  Args:
      template: Format string with one placeholder for quantity.
      quantity: Quantity to aggregate.
      aggregate: Aggregation function used to combine the
          quantities. The result is inserted into the template to
          produce the final log message.
docstr_tok: ["Add","a","log","message",",","which","will","be","combined","by","template",".","Args",":","template",":","Format","string","with","one","placeholder","for","quantity",".","quantity",":","Quantity","to","aggregate",".","aggregate",":","Aggregation","function","used","to","combine","the","quantities",".","The","result","is","inserted","into","the","template","to","produce","the","final","log","message","."]
code: def add(
      self,
      template: str,
      *,
      quantity: Any,
      aggregate: Callable[[Any, Any], Any],
  ) -> None:
      """Add a log message, which will be combined by template.
  
      Args:
          template: Format string with one placeholder for quantity.
          quantity: Quantity to aggregate.
          aggregate: Aggregation function used to combine the
              quantities. The result is inserted into the template to
              produce the final log message.
      """
      with self.lock:
          # Enforce proper sentence structure.
          if not template.endswith("."):
              template += "."
          if template in self.events_by_key:
              self.events_by_key[template] = aggregate(
                  self.events_by_key[template], quantity
              )
          else:
              self.events_by_key[template] = quantity
  
file_path: ray/python/ray/autoscaler/_private/event_summarizer.py
imports: import time
  from threading import RLock
  from typing import Any, Callable, Dict, List
label_desc: Use image node_id 2 for calling the EventSummarizer obj's underlying member method code with example usage: obj.add(template) without return types