HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.109.1.lve.el8.x86_64 #1 SMP Thu Mar 5 20:23:46 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.30
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/ext/tornado/__pycache__/log.cpython-310.pyc
o

�N�gm0�@s�dZddlmZmZmZddlZddlZddlZddlm	Z	ddl
mZmZzddl
Z
Wney7dZ
YnwzddlZWneyIdZYnwe�d�Ze�d�Ze�d�Zd	d
�Zdd�ZGd
d�dej�Zddd�Zddd�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.
�)�absolute_import�division�print_functionN)�_unicode)�unicode_type�basestring_typeztornado.accessztornado.applicationztornado.generalcCs�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�H/opt/saltstack/salt/lib/python3.10/site-packages/salt/ext/tornado/log.py�_stderr_supports_color9s2�
���
�
����rcCs&zt|�WStyt|�YSw�N)r�UnicodeDecodeError�repr)�srrr�
_safe_unicodeKs

�rc@sPeZdZdZdZdZejdejdej	dej
diZeedd	efd
d�Zdd
�Z
dS)�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�����%Tc	Cs�tjj||d�||_i|_|rjt�rjtdurUt�d�p"t�d�p"d}dtj	kr.dkr5nnt
|d�}|��D]\}}t
t�||�d�|j|<q9t
t�d	�d�|_
dS|��D]\}}d
||j|<qYd|_
dSd|_
dS)a^
        :arg bool color: Enables color support.
        :arg string 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 string datefmt: Datetime format.
          Used for formatting ``(asctime)`` placeholder in ``prefix_fmt``.

        .. versionchanged:: 3.2

           Added ``fmt`` and ``datefmt`` arguments.
        )�datefmtNZsetafZsetf�)rr)rrr�asciiZsgr0z[2;3%dmz)�logging�	Formatter�__init__�_fmt�_colorsrr
Ztigetstrr�version_infor�itemsZtparm�_normal)	�self�fmtr �style�colorr	Zfg_color�levelno�coderrrr%ss&

��


zLogFormatter.__init__c
Csz|��}t|t�sJ�t|�|_Wnty,}zd||jf|_WYd}~nd}~ww|�||j�|_	|j
|jvrG|j|j
|_|j
|_nd|_|_|j|j}|jr`|js`|�|j�|_|jr{|��g}|�dd�|j�d�D��d�|�}|�dd�S)NzBad message (%r): %rr!css�|]}t|�VqdSr)r)�.0Zlnrrr�	<genexpr>�s�z&LogFormatter.format.<locals>.<genexpr>�
z
    )�
getMessage�
isinstancerr�messager�__dict__�
formatTimer �asctimer/r'r.r*Z	end_colorr&�exc_info�exc_text�formatException�rstrip�extend�split�join�replace)r+�recordr6�e�	formatted�linesrrr�format�s,��


zLogFormatter.formatN)�__name__�
__module__�__qualname__�__doc__�DEFAULT_FORMATZDEFAULT_DATE_FORMATr#�DEBUG�INFO�WARNING�ERRORZDEFAULT_COLORSr%rFrrrrrRs�
�/rcCs |durddl}|jjjj}|jdus|j��dkrdS|dur$t��}|�tt|j�	���|j
rp|j}|dkrFtjj
|j
|j|jd�}n|dkrYtjj|j
|j|j|jd�}n
dd	|}t|��|�td
d��|�|�|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`.
    NrZnone�size)�filenameZmaxBytes�backupCount�time)rQZwhen�intervalrRz.The value of log_rotate_mode option should be z"size" or "time", not "%s".F)r.)�salt.ext.tornado.options�ext�tornado�optionsr#�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)rX�logger�saltZrotate_modeZchannelZ
error_messagerrr�enable_pretty_logging�sF���
�rkcs��durddl}|jjjj��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�metavarrgz�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.)�typermrnr]�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))rprmrornr`i�z%max size of log files before rolloverra�
znumber of log files to keeprbZmidnightzcspecify the type of TimedRotatingFileHandler interval other options:('S', 'M', 'H', 'D', 'W0'-'W6')rcrz$The interval value of timed rotatingr^rPz(The mode of rotating files(time or size)cst��Sr)rkr�rXrr�<lambda>#sz(define_logging_options.<locals>.<lambda>)	rUrVrWrXZdefine�bool�str�intZadd_parse_callback)rXrjrrsr�define_logging_options�s:	�
��
�
�
�
�
�rx)NNr)rJZ
__future__rrrr#Zlogging.handlersrZsalt.ext.tornado.escaperZsalt.ext.tornado.utilrrr�ImportErrorr
rZZ
access_logZapp_logZgen_logrrr$rrkrxrrrr�<module>s2��



*