[docs]classLoggingCallbackHandler(FunctionCallbackHandler):"""Tracer that logs via the input Logger."""name:str="logging_callback_handler"
[docs]def__init__(self,logger:logging.Logger,log_level:int=logging.INFO,extra:Optional[dict]=None,**kwargs:Any,)->None:"""Initialize the LoggingCallbackHandler. Args: logger: the logger to use for logging log_level: the logging level (default: logging.INFO) extra: the extra context to log (default: None) **kwargs: additional keyword arguments. """log_method=getattr(logger,logging.getLevelName(level=log_level).lower())defcallback(text:str)->None:log_method(text,extra=extra)super().__init__(function=callback,**kwargs)