
    qiO	                         d Z ddlmZmZmZ ddlmZ ddlmZm	Z	m
Z
mZmZ ddlmZmZ  ej                   d      Z G d d	e      Zy
)zUFrame logging utilities for debugging and monitoring frame flow in Pipecat pipelines.    )OptionalTupleType)logger)BotSpeakingFrameFrameInputAudioRawFrameOutputAudioRawFrameUserSpeakingFrame)FrameDirectionFrameProcessorT)ansic                   f     e Zd ZdZddeeeeffdee	   de
ee   df   f fdZded	ef fd
Z xZS )FrameLoggera  A frame processor that logs frame information for debugging purposes.

    This processor intercepts frames passing through the pipeline and logs
    their details with configurable formatting and filtering. Useful for
    debugging frame flow and understanding pipeline behavior.
    r   Ncolorignored_frame_types.c                 L    t         |           || _        || _        || _        y)a  Initialize the frame logger.

        Args:
            prefix: Text prefix to add to log messages. Defaults to "Frame".
            color: ANSI color code for log message formatting. If None, no coloring is applied.
            ignored_frame_types: Tuple of frame types to exclude from logging.
                Defaults to common high-frequency frames like audio and speaking frames.
        N)super__init___prefix_color_ignored_frame_types)selfprefixr   r   	__class__s       K/opt/pipecat/venv/lib/python3.12/site-packages/pipecat/processors/logger.pyr   zFrameLogger.__init__!   s&    & 	$7!    frame	directionc                 z  K   t         |   ||       d{    | j                  rtt        || j                        s^|t        j
                  u rdnd}| d| j                   d| }| j                  rd| j                   d| d}t        j                  |       | j                  ||       d{    y7 7 w)zProcess and log frame information.

        Args:
            frame: The frame to process and potentially log.
            direction: The direction of frame flow in the pipeline.
        N<> z: z</>)r   process_framer   
isinstancer   UPSTREAMr   r   r   debug
push_frame)r   r   r   dirmsgr   s        r   r$   zFrameLogger.process_frame9   s      g#E9555$$Zt?X?X-Y"n&=&==#3CE4<<.5'2C{{$++auC0LLooeY/// 	6 	0s"   B;B7BB;1B92B;9B;)__name__
__module____qualname____doc__r   r   r	   r
   r   strr   r   r   r   r   r$   __classcell__)r   s   @r   r   r      sd     #	8
	8 }8 #4;#34	800 0> 0 0r   r   N)r.   typingr   r   r   logurur   pipecat.frames.framesr   r   r	   r
   r   "pipecat.processors.frame_processorr   r   optr    r   r   <module>r7      s@    \ ( (   N		00. 00r   