HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/env/lib/python3.10/site-packages/tornado/__pycache__/log.cpython-310.pyc
o

we1�@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�colorsrT�wrapped_stderrF)�hasattr�sys�stderrr
�curses�	setupterm�tigetnum�colorama�getattr�
initialise�object�	Exception�rr�D/home/arjun/projects/env/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(N�setaf�setf��ascii�sgr0�z[2;3%dmz)�logging�	Formatter�__init__�_fmt�_colorsrr�tigetstr�itemsr�tparm�_normal)
�selfr'r(r)r*r�fg_color�levelno�code�normalrrrr3ts$
�



zLogFormatter.__init__�recordc
Csz|��}t|t�sJ�t|�|_Wnty,}zd||jf|_WYd}~nd}~ww|�|tt	|j
��|_|j|j
vrJ|j
|j|_|j|_nd|_|_|j|j}|jrc|jsc|�|j�|_|jr~|��g}|�dd�|j�d�D��d�|�}|�dd�S)NzBad message (%r): %rr0css�|]}t|�VqdSr)r)�.0�lnrrr�	<genexpr>�s�z&LogFormatter.format.<locals>.<genexpr>�
z
    )�
getMessage�
isinstancerr�messager�__dict__�
formatTimer�strr(�asctimer<r5r*r9�	end_colorr4�exc_info�exc_text�formatException�rstrip�extend�split�join�replace)r:r?rF�e�	formatted�linesrrr�format�s,��


zLogFormatter.format)�__name__�
__module__�__qualname__�__doc__�DEFAULT_FORMAT�DEFAULT_DATE_FORMATr1�DEBUG�INFO�WARNING�ERROR�CRITICAL�DEFAULT_COLORSrI�boolr�intr3rrWrrrrr Qs:�
�����
�
�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)�filename�maxBytes�backupCount�encoding�time)rj�when�intervalrlrmz.The value of log_rotate_mode option should be z"size" or "time", not "%s".F)r*)�tornado.optionsrfr1�lower�	getLogger�setLevelr�upper�log_file_prefix�log_rotate_mode�handlers�RotatingFileHandler�log_file_max_size�log_file_num_backups�TimedRotatingFileHandler�log_rotate_when�log_rotate_interval�
ValueError�setFormatterr �
addHandler�
log_to_stderr�
StreamHandler)rfrg�tornado�rotate_mode�channel�
error_messagerrr�enable_pretty_logging�sJ��	��
�r�cs��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.
    Nrr1�infozSSet the Python log level. If 'none', tornado won't touch the logging configuration.zdebug|info|warning|error|none)�default�help�metavarr�z�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.)�typer�r�rv�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))r�r�r�r�rzi�z%max size of log files before rolloverr{�
znumber of log files to keepr}�midnightzcspecify the type of TimedRotatingFileHandler interval other options:('S', 'M', 'H', 'D', 'W0'-'W6')r~r$z$The interval value of timed rotatingrwriz(The mode of rotating files(time or size)cst��Sr)r�r�rfrr�<lambda>Wsz(define_logging_options.<locals>.<lambda>)rqrf�definerdrIre�add_parse_callback)rfr�rr�r�define_logging_options	sd	�	�
����	��r�)NNr)r[r1�logging.handlersr�tornado.escaper�tornado.utilrrr�ImportErrorr�typingrrrrrs�
access_log�app_log�gen_logrdrrIrr2r �Loggerr�r�rrrr�<module>sB��


���
�2