File: //lib/python3/dist-packages/twisted/python/__pycache__/log.cpython-38.pyc
U
�bW � @ s� d Z ddlZddlZddlZddlmZmZ ddlmZ ddlm Z m
Z
mZmZm
Z
ddlmZ ddlmZmZmZmZmZmZmZmZ ddlm Z dd l!m"Z# dd
l$m%Z%m&Z&m'Z'm(Z( ddl)m*Z* ee+e f Z,G dd
� d
�Z-G dd� de�Z.e%�/e-ddi� dd� Z0dd� Z1dEdd�Z2e2Z3G dd� d�ZG dd� d�Ze*e� de4� k�r�dd� Z5eeeed�Z6e5e6j7�d d!� �Z7e5e6j8�d"d#� �Z8e5e6j9�d$d%� �Z9e5e6j:�d&d'� �Z:e+ee+e f e+d(�d)d*�Z;e,ee+ d+�d,d-�Z<G d.d/� d/e�Z=G d0d1� d1e=�Z>G d2d3� d3e=�Z?G d4d5� d5�Z@d6d7� ZAdFd9d:�ZBG d;d<� d<�ZCd=d>� ZDd?e4� k�r�ee� ejEeFejGd@d�dA�aHee� ejIeFejJd@d�dA�ZKG dBdC� dCe=�ZLdDe4� k�r�eL� ZMdS )Gz%
Logging and metrics infrastructure.
� N)�ABC�abstractmethod)�datetime)�Any�BinaryIO�Dict�Optional�cast)� Interface)�LegacyLogObserverWrapper�Logger�LoggingFile�LogLevel�LogPublisher�STDLibLogObserver�globalLogBeginner�globalLogPublisher)�LogBeginner)�publishToNewObserver)�context�failure�reflect�util)�synchronizec @ s e Zd ZdZdS )�ILogContextz�
Actually, this interface is just a synonym for the dictionary interface,
but it serves as a key for the default information in a log.
I do not inherit from C{Interface} because the world is a cruel place.
N)�__name__�
__module__�__qualname__�__doc__� r r �4/usr/lib/python3/dist-packages/twisted/python/log.pyr % s r c @ s e Zd ZdZedd�dd�ZdS )�ILogObserverz�
An observer which can do something with log events.
Given that most log observers are actually bound methods, it's okay to not
explicitly declare provision of this interface.
N�� eventDict�returnc C s dS )a6
Log an event.
@param eventDict: A dictionary with arbitrary keys. However, these
keys are often available:
- C{message}: A C{tuple} of C{str} containing messages to be
logged.
- C{system}: A C{str} which indicates the "system" which is
generating this event.
- C{isError}: A C{bool} indicating whether this event represents
an error.
- C{failure}: A L{failure.Failure} instance
- C{why}: Used as header of the traceback in case of errors.
- C{format}: A string format used in place of C{message} to
customize the event. The intent is for the observer to format
a message by doing something like C{format % eventDict}.
Nr )r# r r r �__call__6 s zILogObserver.__call__)r r r r � EventDictr% r r r r r! . s r! �system�-c O s0 t �t��� }|�| � t jt|i|f|�|�S �N)r �getr �copy�update�call)�ctx�func�args�kwZnewCtxr r r �callWithContextM s
r2 c O s� z| � � }W n6 tk
r" � Y n" tk
rB d}t|d� Y nX ztd|i|f|�|�W S tk
rr � Y n tk
r� t|d� Y nX dS )z�
Utility method which wraps a function in a try:/except:, logs a failure if
one occurs, and uses the system's logPrefix.
z(buggy logPrefix method))r'