HEX
Server: LiteSpeed
System: Linux s1049.use1.mysecurecloudhost.com 4.18.0-477.27.2.lve.el8.x86_64 #1 SMP Wed Oct 11 12:32:56 UTC 2023 x86_64
User: xedaptot (3356)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/tornado/__pycache__/log.cpython-310.pyc
o

;j1�@s dZddlZddlZddlZddlmZddlmZmZzddl	Z	Wne
y-dZ	YnwzddlZWne
y?dZYnwddlm
Z
mZmZmZe�d�Ze�d�Ze�d�Zd	efd
d�Zded	efd
d�ZGdd�dej�Z	ddedeejd	dfdd�Zdded	dfdd�ZdS)aHLogging support for Tornado.

Tornado uses three logger streams:

* ``tornado.access``: Per-request logging for Tornado's HTTP servers (and
  potentially other servers in the future)
* ``tornado.application``: Logging of errors from application code (i.e.
  uncaught exceptions from callbacks)
* ``tornado.general``: General-purpose logging, including any errors
  or warnings from Tornado itself.

These streams may be configured independently using the standard library's
`logging` module.  For example, you may wish to send ``tornado.access`` logs
to a separate file for analysis.
�N)�_unicode)�unicode_type�basestring_type)�Dict�Any�cast�Optionalztornado.accessztornado.applicationztornado.general�returncCs�z:ttjd�r/tj��r2trt��t�d�dkrWdSWdStr5tjttj	dt
��ur8WdSWdSWdSWdSWdStyDYdSw)N�isatty�colorsrTZwrapped_stderrF)�hasattr�sys�stderrr
�cursesZ	setuptermZtigetnum�colorama�getattrZ
initialise�object�	Exception�rr�?/opt/saltstack/salt/lib/python3.10/site-packages/tornado/log.py�_stderr_supports_color7s2��
����	���r�scCs&zt|�WStyt|�YSw�N)r�UnicodeDecodeError�repr)rrrr�
_safe_unicodeJs

�rc
@s�eZdZdZdZdZejdejdej	dej
dejdiZeed	d
efde
de
d
e
dedeeefddfdd�Zdede
fdd�ZdS)�LogFormatterapLog formatter used in Tornado.

    Key features of this formatter are:

    * Color support when logging to a terminal that supports it.
    * Timestamps on every log line.
    * Robust against str/bytes encoding problems.

    This formatter is enabled automatically by
    `tornado.options.parse_command_line` or `tornado.options.parse_config_file`
    (unless ``--logging=none`` is used).

    Color support on Windows versions that do not support ANSI color codes is
    enabled by use of the colorama__ library. Applications that wish to use
    this must first initialize colorama with a call to ``colorama.init``.
    See the colorama documentation for details.

    __ https://pypi.python.org/pypi/colorama

    .. versionchanged:: 4.5
       Added support for ``colorama``. Changed the constructor
       signature to be compatible with `logging.config.dictConfig`.
    zV%(color)s[%(levelname)1.1s %(asctime)s %(module)s:%(lineno)d]%(end_color)s %(message)sz%y%m%d %H:%M:%S������%T�fmt�datefmt�style�colorrr	Nc
Cs�tjj||d�||_i|_|rct�rctdurNt�d�p"t�d�p"d}|��D]\}}t	t�
||�d�|j|<q't�d�}	|	durIt	|	d�|_dSd|_dS|��D]\}}d	||j|<qRd
|_dSd|_dS)aX
        :arg bool color: Enables color support.
        :arg str fmt: Log message format.
          It will be applied to the attributes dict of log records. The
          text between ``%(color)s`` and ``%(end_color)s`` will be colored
          depending on the level if color support is on.
        :arg dict colors: color mappings from logging level to terminal color
          code
        :arg str datefmt: Datetime format.
          Used for formatting ``(asctime)`` placeholder in ``prefix_fmt``.

        .. versionchanged:: 3.2

           Added ``fmt`` and ``datefmt`` arguments.
        )r$NZsetafZsetf��asciiZsgr0�z[2;3%dmz)�logging�	Formatter�__init__�_fmt�_colorsrrZtigetstr�itemsrZtparm�_normal)
�selfr#r$r%r&rZfg_color�levelno�codeZnormalrrrr,ts$
�



zLogFormatter.__init__�recordc
Csz|��}t|t�sJ�t|�|_Wnty.}zd|�d|j��|_WYd}~nd}~ww|�|tt	|j
��|_|j|j
vrL|j
|j|_|j|_nd|_|_|j|j}|jre|jse|�|j�|_|jr�|��g}|�dd�|j�d�D��d�|�}|�dd�S)Nz
Bad message (z): r)css�|]}t|�VqdSr)r)�.0Zlnrrr�	<genexpr>�s�z&LogFormatter.format.<locals>.<genexpr>�
z
    )�
getMessage�
isinstancerr�messager�__dict__�
formatTimer�strr$�asctimer2r.r&r0Z	end_colorr-�exc_info�exc_text�formatException�rstrip�extend�split�join�replace)r1r4r:�e�	formatted�linesrrr�format�s, ��


zLogFormatter.format)�__name__�
__module__�__qualname__�__doc__�DEFAULT_FORMATZDEFAULT_DATE_FORMATr*�DEBUG�INFO�WARNING�ERROR�CRITICALZDEFAULT_COLORSr=�boolr�intr,rrJrrrrrQs:�
�����
�
�4r�options�loggercCs |durddl}|jj}|jdus|j��dkrdS|dur"t��}|�tt|j����|jrp|j	}|dkrEtj
j|j|j|j
dd�}n|dkrYtj
j|j|j|j|j
dd�}n
d	d
|}t|��|�tdd��|�|�|js{|jdur�|j
s�t��}|�t��|�|�dSdSdS)
z�Turns on formatted logging output as configured.

    This is called automatically by `tornado.options.parse_command_line`
    and `tornado.options.parse_config_file`.
    Nr�none�sizezutf-8)�filenameZmaxBytes�backupCount�encoding�time)r[Zwhen�intervalr\r]z.The value of log_rotate_mode option should be z"size" or "time", not "%s".F)r&)�tornado.optionsrWr*�lower�	getLogger�setLevelr�upper�log_file_prefix�log_rotate_mode�handlersZRotatingFileHandler�log_file_max_size�log_file_num_backupsZTimedRotatingFileHandler�log_rotate_when�log_rotate_interval�
ValueError�setFormatterr�
addHandler�
log_to_stderr�
StreamHandler)rWrX�tornadoZrotate_modeZchannelZ
error_messagerrr�enable_pretty_logging�sJ��	��
�rrcs��durddl}|jj��jddddd��jdtdd	d
��jdtddd
d��jdtddd
��jdtddd
��jdtddd
��jdtddd
��jdtddd
����fdd��dS) aBAdd logging-related flags to ``options``.

    These options are present automatically on the default options instance;
    this method is only necessary if you have created your own `.OptionParser`.

    .. versionadded:: 4.2
        This function existed in prior versions but was broken and undocumented until 4.2.
    Nrr*�infozSSet the Python log level. If 'none', tornado won't touch the logging configuration.zdebug|info|warning|error|none)�default�help�metavarroz�Send log output to stderr (colorized if possible). By default use stderr if --log_file_prefix is not set and no other logging is configured.)�typertrure�PATHz�Path prefix for log files. Note that if you are running multiple tornado processes, log_file_prefix must be different for each of them (e.g. include the port number))rwrtrvrurhi�z%max size of log files before rolloverri�
znumber of log files to keeprjZmidnightzcspecify the type of TimedRotatingFileHandler interval other options:('S', 'M', 'H', 'D', 'W0'-'W6')rkr z$The interval value of timed rotatingrfrZz(The mode of rotating files(time or size)cst��Sr)rrr�rWrr�<lambda>Wsz(define_logging_options.<locals>.<lambda>)r`rWZdefinerUr=rVZadd_parse_callback)rWrqrrzr�define_logging_options	sd	�	�
����	��r|)NNr)rNr*Zlogging.handlersr
Ztornado.escaperZtornado.utilrrr�ImportErrorr�typingrrrrrbZ
access_logZapp_logZgen_logrUrr=rr+r�Loggerrrr|rrrr�<module>sB��


���
�2