LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
    • Overview
    • Caches
    • Callbacks
    • Documents
    • Document loaders
    • Embeddings
    • Exceptions
    • Language models
    • Serialization
    • Output parsers
    • Prompts
    • Rate limiters
    • Retrievers
    • Runnables
    • Utilities
    • Vector stores
    MCP Adapters
    Standard Tests
    Text Splitters
    ⌘I

    LangChain Assistant

    Ask a question to get started

    Enter to send•Shift+Enter new line

    Menu

    OverviewCachesCallbacksDocumentsDocument loadersEmbeddingsExceptionsLanguage modelsSerializationOutput parsersPromptsRate limitersRetrieversRunnablesUtilitiesVector stores
    MCP Adapters
    Standard Tests
    Text Splitters
    Language
    Theme
    Pythonlangchain-coretracerslog_streamLogStreamCallbackHandler
    Class●Since v0.1

    LogStreamCallbackHandler

    Copy
    LogStreamCallbackHandler(
      self,
      *,
      auto_close: bool = True,
      include_names: Sequence[str

    Bases

    BaseTracer_StreamingCallbackHandler

    Constructors

    Attributes

    Methods

    Inherited fromBaseTracer

    Methods

    Mon_chat_model_start
    —

    Start a trace for a chat model run.

    Mon_llm_start
    —

    Start a trace for an LLM run.

    Mon_llm_new_token
    —

    Run on new LLM token.

    Mon_retry
    View source on GitHub
    ]
    |
    None
    =
    None
    ,
    include_types
    :
    Sequence
    [
    str
    ]
    |
    None
    =
    None
    ,
    include_tags
    :
    Sequence
    [
    str
    ]
    |
    None
    =
    None
    ,
    exclude_names
    :
    Sequence
    [
    str
    ]
    |
    None
    =
    None
    ,
    exclude_types
    :
    Sequence
    [
    str
    ]
    |
    None
    =
    None
    ,
    exclude_tags
    :
    Sequence
    [
    str
    ]
    |
    None
    =
    None
    ,
    _schema_format
    :
    Literal
    [
    'original'
    ,
    'streaming_events'
    ]
    =
    'streaming_events'
    )
    —

    Run on retry.

    Mon_llm_end
    —

    End a trace for an LLM or chat model run.

    Mon_llm_error
    —

    Handle an error for an LLM run.

    Mon_chain_start
    —

    Start a trace for a chain run.

    Mon_chain_end
    —

    End a trace for a chain run.

    Mon_chain_error
    —

    Handle an error for a chain run.

    Mon_tool_start
    —

    Start a trace for a tool run.

    Mon_tool_end
    —

    End a trace for a tool run.

    Mon_tool_error
    —

    Handle an error for a tool run.

    Mon_retriever_start
    —

    Run when the Retriever starts running.

    Mon_retriever_error
    —

    Run when Retriever errors.

    Mon_retriever_end
    —

    Run when the Retriever ends running.

    Inherited fromBaseCallbackHandler

    Attributes

    Araise_error: bool
    —

    Whether to raise an error if an exception occurs.

    Arun_inline: bool
    —

    Whether to run the callback inline.

    Aignore_llm: bool
    —

    Whether to ignore LLM callbacks.

    Aignore_retry: bool
    —

    Whether to ignore retry callbacks.

    Aignore_chain: bool
    —

    Whether to ignore chain callbacks.

    Aignore_agent: bool
    —

    Whether to ignore agent callbacks.

    Aignore_retriever: bool
    —

    Whether to ignore retriever callbacks.

    Aignore_chat_model: bool
    —

    Whether to ignore chat model callbacks.

    Aignore_custom_event: bool
    —

    Ignore custom event.

    Inherited fromLLMManagerMixin

    Methods

    Mon_llm_new_token
    —

    Run on new output token.

    Mon_llm_end
    —

    Run when LLM ends running.

    Mon_llm_error
    —

    Run when LLM errors.

    Inherited fromChainManagerMixin

    Methods

    Mon_chain_end
    —

    Run when chain ends running.

    Mon_chain_error
    —

    Run when chain errors.

    Mon_agent_action
    —

    Run on agent action.

    Mon_agent_finish
    —

    Run on the agent end.

    Inherited fromToolManagerMixin

    Methods

    Mon_tool_end
    —

    Run when the tool ends running.

    Mon_tool_error
    —

    Run when tool errors.

    Inherited fromRetrieverManagerMixin

    Methods

    Mon_retriever_error
    —

    Run when Retriever errors.

    Mon_retriever_end
    —

    Run when Retriever ends running.

    Inherited fromCallbackManagerMixin

    Methods

    Mon_llm_start
    —

    Run when LLM starts running.

    Mon_chat_model_start
    —

    Run when a chat model starts running.

    Mon_retriever_start
    —

    Run when the Retriever starts running.

    Mon_chain_start
    —

    Run when a chain starts running.

    Mon_tool_start
    —

    Run when the tool starts running.

    Inherited fromRunManagerMixin

    Methods

    Mon_text
    —

    Run on an arbitrary text.

    Mon_retry
    —

    Run on a retry event.

    Mon_custom_event
    —

    Override to define a handler for a custom event.

    Parameters

    NameTypeDescription
    auto_closebool
    Default:True

    Whether to close the stream when the root run finishes.

    include_namesSequence[str] | None
    Default:None

    Only include runs from Runnable objects with matching names.

    include_typesSequence[str] | None
    Default:None
    include_tagsSequence[str] | None
    Default:None
    exclude_namesSequence[str] | None
    Default:None
    exclude_typesSequence[str] | None
    Default:None
    exclude_tagsSequence[str] | None
    Default:None
    _schema_formatLiteral['original', 'streaming_events']
    Default:'streaming_events'
    constructor
    __init__
    NameType
    auto_closebool
    include_namesSequence[str] | None
    include_typesSequence[str] | None
    include_tagsSequence[str] | None
    exclude_namesSequence[str] | None
    exclude_typesSequence[str] | None
    exclude_tagsSequence[str] | None
    _schema_formatLiteral['original', 'streaming_events']
    attribute
    auto_close: auto_close
    attribute
    include_names: include_names
    attribute
    include_types: include_types
    attribute
    include_tags: include_tags
    attribute
    exclude_names: exclude_names
    attribute
    exclude_types: exclude_types
    attribute
    exclude_tags: exclude_tags
    attribute
    lock
    attribute
    send_stream
    attribute
    receive_stream
    attribute
    root_id: UUID | None
    method
    send

    Send a patch to the stream, return False if the stream is closed.

    method
    tap_output_aiter

    Tap an output async iterator to stream its values to the log.

    method
    tap_output_iter

    Tap an output iterator to stream its values to the log.

    method
    include_run

    Check if a Run should be included in the log.

    Tracer that streams run logs to a stream.

    Only include runs from Runnable objects with matching types.

    Only include runs from Runnable objects with matching tags.

    Exclude runs from Runnable objects with matching names.

    Exclude runs from Runnable objects with matching types.

    Exclude runs from Runnable objects with matching tags.

    Primarily changes how the inputs and outputs are handled.

    For internal use only. This API will change.

    • 'original' is the format used by all current tracers. This format is slightly inconsistent with respect to inputs and outputs.
    • 'streaming_events' is used for supporting streaming events, for internal usage. It will likely change in the future, or be deprecated entirely in favor of a dedicated async tracer for streaming events.