Server IP : 209.38.156.173 / Your IP : 216.73.216.122 [ Web Server : Apache/2.4.52 (Ubuntu) System : Linux lakekumayuhotel 5.15.0-136-generic #147-Ubuntu SMP Sat Mar 15 15:53:30 UTC 2025 x86_64 User : root ( 0) PHP Version : 8.1.2-1ubuntu2.22 Disable Function : NONE Domains : 2 Domains MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /usr/lib/python3/dist-packages/twisted/logger/__pycache__/ |
Upload File : |
o �b�! � @ s� d Z ddlZddlZddlmZmZmZmZmZ ddl m Z ddlmZ ddl mZ ddlmZ dd lmZmZ dd lmZ ddlmZ ddlmZ dd lmZ ddlmZ ddlmZ dZ G dd� d�Z!e� Z"e!e"ej#ee�Z$dS )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 @ s� e Zd ZdZdZ ddedee dedede e d dfd d�Z ddee deded dfdd�Z ddedee dede de ee de e d dfdd�ZdS )�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 C s~ |du r| j }t|d�| _|| _t|d�| _|| _|| _t| jt t |dd� �ttj d�g��| _d| _|�| j� |j| _dS )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 S s t | ddd�d S )NF)�includeTimestamp� includeSystem� r )�event� r# �8/usr/lib/python3/dist-packages/twisted/logger/_global.py�<lambda>a s ��z&LogBeginner.__init__.<locals>.<lambda>)�defaultLogLevel)� r )�_DEFAULT_BUFFER_SIZEr �_initialBuffer� _publisherr �_log�_stdio�_warningsModuler r r r r �critical�_temporaryObserver�_previousBegin�addObserver�showwarning�_oldshowwarning)�selfr r r r r r# r# r$ �__init__F s( � ��zLogBeginner.__init__FT� observers� discardBuffer�redirectStandardIOc C s� t d�}|jj}|j}|D ]}| j�|� q | jdur4| j�| j� |s+| j� | j� d| _| j | j_ n| j\}} | j jt|||| d� ||f| _|rVdtjfdtjfg} ng } | D ]!\}}t| j|�} tt|| jd�|t| dd�d�}t| j||� qZdS ) 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�levelr@ )r �f_code�co_filename�f_linenor* r1 r/ �removeObserverr) �replayTor2 r- r0 r+ �warn�MORE_THAN_ONCE_WARNINGr �info�error�getattrr, r r �setattr)r4 r6 r7 r8 �caller�filename�linenor �previousFile�previousLine�streams�streamrB � oldStream�loggingFiler# r# r$ �beginLoggingToo s@ $ � ��zLogBeginner.beginLoggingTo�message�categoryrO rP �file�linec C s>