HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //usr/lib/python3/dist-packages/twisted/logger/__pycache__/_observer.cpython-38.pyc
U


W[�@s\dZddlmZmZddlmZddlmZdZGdd�de�Z	ee	�Gd	d
�d
e
��ZdS)z
Basic log observers.
�)�	Interface�implementer)�Failure�)�LoggerzITemporarily disabling observer {observer} due to exception: {log_failure}c@seZdZdZdd�ZdS)�ILogObservera
    An observer which can handle log events.

    Unlike most interfaces within Twisted, an L{ILogObserver} I{must be
    thread-safe}.  Log observers may be called indiscriminately from many
    different threads, as any thread may wish to log a message at any time.
    cCsdS)a�
        Log an event.

        @type event: C{dict} with (native) C{str} keys.
        @param event: A dictionary with arbitrary keys as defined by the
            application emitting logging events, as well as keys added by the
            logging system.  The logging system reserves the right to set any
            key beginning with the prefix C{"log_"}; applications should not
            use any key so named.  Currently, the following keys are used by
            the logging system in some way, if they are present (they are all
            optional):

                - C{"log_format"}: a PEP-3101-style format string which draws
                  upon the keys in the event as its values, used to format the
                  event for human consumption.

                - C{"log_flattened"}: a dictionary mapping keys derived from
                  the names and format values used in the C{"log_format"}
                  string to their values.  This is used to preserve some
                  structured information for use with
                  L{twisted.logger.extractField}.

                - C{"log_trace"}: A L{list} designed to capture information
                  about which L{LogPublisher}s have observed the event.

                - C{"log_level"}: a L{log level
                  <twisted.logger.LogLevel>} constant, indicating the
                  importance of and audience for this event.

                - C{"log_namespace"}: a namespace for the emitter of the event,
                  given as a unicode string.

                - C{"log_system"}: a string indicating the network event or
                  method call which resulted in the message being logged.
        N�)�eventrr�:/usr/lib/python3/dist-packages/twisted/logger/_observer.py�__call__szILogObserver.__call__N)�__name__�
__module__�__qualname__�__doc__rrrrr
rsrc@s8eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�LogPublisherz�
    I{ILogObserver} that fans out events to other observers.

    Keeps track of a set of L{ILogObserver} objects and forwards
    events to each.
    cGst|�|_t|d�|_dS)N��observer)�list�
_observersr�log)�selfZ	observersrrr
�__init__Os
zLogPublisher.__init__cCs0t|�std�|���||jkr,|j�|�dS)zq
        Registers an observer with this publisher.

        @param observer: An L{ILogObserver} to add.
        zObserver is not callable: {0!r}N)�callable�	TypeError�formatr�append�rrrrr
�addObserverTs
zLogPublisher.addObservercCs*z|j�|�Wntk
r$YnXdS)zv
        Unregisters an observer with this publisher.

        @param observer: An L{ILogObserver} to remove.
        N)r�remove�
ValueErrorrrrr
�removeObserver`szLogPublisher.removeObserverc	s�d�kr��fdd�}nd}g}�jD]F}|dk	r:||�z|��Wq&tk
rj|�|t�f�Yq&Xq&|D]"\}}��|�}|jt||d�qrdS)z8
        Forward events to contained observers.
        �	log_tracecs�d��|f�dS)z�
                Add tracing information for an observer.

                @param observer: an observer being forwarded to
                @type observer: L{ILogObserver}
                r!N)rr�r	rrr
�traceqsz$LogPublisher.__call__.<locals>.traceN)�failurer)r�	Exceptionrr�_errorLoggerForObserverr$�OBSERVER_DISABLED)rr	r#ZbrokenObserversrZbrokenObserverr$ZerrorLoggerrr"r
rls$	

�zLogPublisher.__call__cs"t�fdd�|jD��}t|d�S)z�
        Create an error-logger based on this logger, which does not contain the
        given bad observer.

        @param observer: The observer which previously had an error.
        @type observer: L{ILogObserver}

        @return: L{None}
        csg|]}|�k	r|�qSrr)�.0Zobsrrr
�
<listcomp>�s�z8LogPublisher._errorLoggerForObserver.<locals>.<listcomp>r)rrr)rrZerrorPublisherrrr
r&�s
�z$LogPublisher._errorLoggerForObserverN)	rr
rrrrr rr&rrrr
rFs$rN)rZzope.interfacerrZtwisted.python.failurerZ_loggerrr'r�objectrrrrr
�<module>s�0