%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/twisted/logger/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/twisted/logger/__pycache__/_global.cpython-312.pyc

�

Ϫ�f�!���dZddlZddlZddlmZmZmZmZmZddl	m
Z
ddlmZddl
mZddlmZdd	lmZmZdd
lmZddlmZddlmZdd
lmZddlmZddlmZdZ Gd�d�Z!e�Z"e!e"ejFee�Z$y)z�
This module includes process-global state associated with the logging system,
and implementation of logic for managing that global state.
�N)�IO�Any�Iterable�Optional�Type)�currentframe)�qual�)�LimitedHistoryLogObserver)�FileLogObserver)�FilteringLogObserver�LogLevelFilterPredicate��eventAsText)�ILogObserver)�LoggingFile)�LogLevel)�Logger)�LogPublisherz�Warning: primary log target selected twice at <{fileNow}:{lineNow}> - previously selected at <{fileThen}:{lineThen}>.  Remove one of the calls to beginLoggingTo.c��eZdZdZdZ	ddedeededede	e
d	dfd
�Z		ddee
ded
ed	dfd�Z		ddedeedede
de	eede	ed	dfd�Zy)�LogBeginnera�
    A L{LogBeginner} holds state related to logging before logging has begun,
    and begins logging when told to do so.  Logging "begins" when someone has
    selected a set of observers, like, for example, a L{FileLogObserver} that
    writes to a file on disk, or to standard output.

    Applications will not typically need to instantiate this class, except
    those which intend to initialize the global logging system themselves,
    which may wish to instantiate this for testing.  The global instance for
    the current process is exposed as
    L{twisted.logger.globalLogBeginner}.

    Before logging has begun, a L{LogBeginner} will:

        1. Log any critical messages (e.g.: unhandled exceptions) to the given
           file-like object.

        2. Save (a limited number of) log events in a
           L{LimitedHistoryLogObserver}.

    @cvar _DEFAULT_BUFFER_SIZE: The default size for the initial log events
        buffer.

    @ivar _initialBuffer: A buffer of messages logged before logging began.
    @ivar _publisher: The log publisher passed in to L{LogBeginner}'s
        constructor.
    @ivar _log: The logger used to log messages about the operation of the
        L{LogBeginner} itself.
    @ivar _stdio: An object with C{stderr} and C{stdout} attributes (like the
        L{sys} module) which will be replaced when redirecting standard I/O.
    @ivar _temporaryObserver: If not L{None}, an L{ILogObserver} that observes
        events on C{_publisher} for this L{LogBeginner}.
    ��N�	publisher�errorStream�stdio�warningsModule�initialBufferSize�returnc	��|�|j}t|��|_||_t	|��|_||_||_t|jtt|d��ttj��g��|_d|_|j!|j�|j"|_y)z�
        Initialize this L{LogBeginner}.

        @param initialBufferSize: The size of the event buffer into which
            events are collected until C{beginLoggingTo} is called.  Or
            C{None} to use the default size.
        N)�size)�observerc�$�t|dd��dzS)NF)�includeTimestamp�
includeSystem�
r)�events �8/usr/lib/python3/dist-packages/twisted/logger/_global.py�<lambda>z&LogBeginner.__init__.<locals>.<lambda>as��+��).�&+�#�
�#��)�defaultLogLevel)�r)�_DEFAULT_BUFFER_SIZEr�_initialBuffer�
_publisherr�_log�_stdio�_warningsModulerr
rrr�critical�_temporaryObserver�_previousBegin�addObserver�showwarning�_oldshowwarning)�selfrrrrrs      r'�__init__zLogBeginner.__init__Fs����$� $� 9� 9��7�=N�O���#����I�.��	����-���:F���� �����)��9J�9J�K�L�
�;
���&������d�5�5�6�-�9�9��r)�	observers�
discardBuffer�redirectStandardIOc
�,�td�}|jj}|j}|D]}|jj|��|j�o|jj|j�|s%|jj|j�d|_|j|j_
n3|j\}}	|jjt||||	��||f|_|r%dt j"fdt j$fg}
ng}
|
D]`\}}t'|j(|�}
t+t-||j��|t'|
dd���}t/|j(||��by)	aw
        Begin logging to the given set of observers.  This will:

            1. Add all the observers given in C{observers} to the
               L{LogPublisher} associated with this L{LogBeginner}.

            2. Optionally re-direct standard output and standard error streams
               to the logging system.

            3. Re-play any messages that were previously logged to that
               publisher to the new observers, if C{discardBuffer} is not set.

            4. Stop logging critical errors from the L{LogPublisher} as strings
               to the C{errorStream} associated with this L{LogBeginner}, and
               allow them to be logged normally.

            5. Re-direct warnings from the L{warnings} module associated with
               this L{LogBeginner} to log messages.

        @note: Since a L{LogBeginner} is designed to encapsulate the transition
            between process-startup and log-system-configuration, this method
            is intended to be invoked I{once}.

        @param observers: The observers to register.
        @param discardBuffer: Whether to discard the buffer and not re-play it
            to the added observers.  (This argument is provided mainly for
            compatibility with legacy concerns.)
        @param redirectStandardIO: If true, redirect standard output and
            standard error to the observers.
        r
N)�fileNow�lineNow�fileThen�lineThen�stdout�stderr)�	namespacer!�encoding)�logger�levelrE)r�f_code�co_filename�f_linenor.r5r3�removeObserverr-�replayTor6r1r4r/�warn�MORE_THAN_ONCE_WARNINGr�info�error�getattrr0rr�setattr)r8r:r;r<�caller�filename�linenor!�previousFile�previousLine�streams�streamrG�	oldStream�loggingFiles               r'�beginLoggingTozLogBeginner.beginLoggingToosg��H�a����=�=�,�,������!�	2�H��O�O�'�'��1�	2��"�"�.��O�O�*�*�4�+B�+B�C� ��#�#�,�,�T�_�_�=�&*�D�#�/3�/?�/?�D� � �,�)-�)<�)<�&�L�,��I�I�N�N�&� ��%�%�
�
� (��0���� �(�-�-�0�8�X�^�^�2L�M�G��G�$�	6�M�F�E�����V�4�I�%������I�� ��J��=��K�

�D�K�K���5�	6r)�message�categoryrTrU�file�linec��|�*|jjd|t|�||��y|j||||||�y)a]
        Twisted-enabled wrapper around L{warnings.showwarning}.

        If C{file} is L{None}, the default behaviour is to emit the warning to
        the log system, otherwise the original L{warnings.showwarning} Python
        function is called.

        @param message: A warning message to emit.
        @param category: A warning category to associate with C{message}.
        @param filename: A file name for the source code file issuing the
            warning.
        @param lineno: A line number in the source file where the warning was
            issued.
        @param file: A file to write the warning message to.  If L{None},
            write to L{sys.stderr}.
        @param line: A line of source code to include with the warning message.
            If L{None}, attempt to read the line from C{filename} and
            C{lineno}.
        Nz*{filename}:{lineno}: {category}: {warning})�warningr^rTrU)r/rMr	r7)r8r]r^rTrUr_r`s       r'r6zLogBeginner.showwarning�sK��8�<��I�I�N�N�<���h��!��
�
�
� � ��(�H�f�d�D�Qr))N)FT)NN)�__name__�
__module__�__qualname__�__doc__r,rrr�objectr�intr9rr�boolr\�strr�Warningr6�r)r'rr!s�� �D��,0�
':��':���W�':��	':�
�':�$�C�=�
':�
�':�X$�#'�	H6��L�)�H6��H6�!�	H6�

�H6�`#'�"�%R��%R��w�-�%R��	%R�
�%R��r�#�w��
%R��s�m�%R�
�%Rr)r)%rf�sys�warnings�typingrrrrr�twisted.python.compatr�twisted.python.reflectr	�_bufferr�_filer�_filterr
r�_formatr�_interfacesr�_ior�_levelsr�_loggerr�	_observerrrNr�globalLogPublisherrC�globalLogBeginnerrlr)r'�<module>r}sr��
�
��4�4�.�'�.�"�B� �%����#���}R�}R�@"�^��� 2�C�J�J��X�N�r)

Zerion Mini Shell 1.0