Ë
    êmxi1  ã                   ó’  — d Z ddlZddlZddlZddlmZ ddlmZmZ 	 ddl	Z		 ddlZddlmZmZmZmZ  ej"                  d«      Z ej"                  d«      Z ej"                  d«      Zd	efd
„Zded	efd„Z G d„ dej2                  «      Z	 ddedeej6                     d	dfd„Zdded	dfd„Zy# e
$ r dZ	Y Œ–w xY w# e
$ r dZY Œžw xY w)aH  Logging 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ÚOptionalztornado.accessztornado.applicationztornado.generalÚreturnc                  ón  — 	 t        t        j                  d«      r‹t        j                  j                  «       rmt        r-t	        j
                  «        t	        j                  d«      dkD  r;yt        r4t        j                  t        t        j                  dt        «       «      u ryy# t        $ r Y yw xY w)NÚisattyÚcolorsr   TÚwrapped_stderrF)ÚhasattrÚsysÚstderrr   ÚcursesÚ	setuptermÚtigetnumÚcoloramaÚgetattrÚ
initialiseÚobjectÚ	Exception© ó    úB/home/htdocs/ttos/venv/lib/python3.12/site-packages/tornado/log.pyÚ_stderr_supports_colorr   7   s�   € ðÜ”3—:‘:˜xÔ(¬S¯Z©Z×->Ñ->Ô-@ÝÜ× Ñ Ô"Ü—?‘? 8Ó,¨qÒ0ØÝÜ—:‘:¤Ü×'Ñ'Ð)9¼6»8ó"ñ ð  ð
 øô	 ò ð 	Øð	ús   ‚A*B( Á-9B( Â(	B4Â3B4Úsc                 óN   — 	 t        | «      S # t        $ r t        | «      cY S w xY w©N)r   ÚUnicodeDecodeErrorÚrepr)r   s    r   Ú_safe_unicoder#   J   s)   € ðÜ˜‹{ÐøÜò Ü�A‹wŠðús   ‚
 �$£$c                   óÚ   — e Zd ZdZdZdZej                  dej                  dej                  dej                  dej                  diZeed	d
efdededededeeef   ddfd„Zdedefd„Zy)ÚLogFormatterap  Log 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Úcolorr   r
   Nc                 óD  — t         j                  j                  | |¬«       || _        i | _        |rèt        «       rÞt        �¦t        j                  d«      xs t        j                  d«      xs d}|j                  «       D ]2  \  }}t        t        j                  ||«      d«      | j                  |<   Œ4 t        j                  d«      }	|	�t        |	d«      | _        yd| _        y|j                  «       D ]  \  }}d	|z  | j                  |<   Œ d
| _        yd| _        y)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Úsetfr   ÚasciiÚsgr0Ú z[2;3%dmz[0m)ÚloggingÚ	FormatterÚ__init__Ú_fmtÚ_colorsr   r   ÚtigetstrÚitemsr   ÚtparmÚ_normal)
Úselfr,   r-   r.   r/   r   Úfg_colorÚlevelnoÚcodeÚnormals
             r   r8   zLogFormatter.__init__t   s  € ô. 	×Ñ×"Ñ" 4°Ð"Ô9ØˆŒ	àˆŒÙÔ+Ô-ÜÐ!Ü!Ÿ?™?¨7Ó3ÒU´v·±ÀvÓ7NÒUÐRU�à%+§\¡\£^ò ‘M�G˜Tô -9ÜŸ™ X¨tÓ4°gó-�D—L‘L Ò)ð	ô  Ÿ™¨Ó0�ØÐ%Ü#/°¸Ó#@�D•Là#%�D•Lð &,§\¡\£^ò A‘M�G˜TØ,9¸DÑ,@�D—L‘L Ò)ðAà(�•àˆD�Lr   Úrecordc                 óR  — 	 |j                  «       }t        |t        «      sJ ‚t        |«      |_        | j                  |t        t        | j                  «      «      |_        |j                  | j                  v r0| j                  |j                     |_        | j                  |_        ndx|_        |_        | j"                  |j                  z  }|j$                  r,|j&                  s | j)                  |j$                  «      |_        |j&                  rS|j+                  «       g}|j-                  d„ |j&                  j/                  d«      D «       «       dj1                  |«      }|j3                  dd«      S # t
        $ r"}d|›d|j                  ›�|_        Y d }~�Œmd }~ww xY w)NzBad message (z): r5   c              3   ó2   K  — | ]  }t        |«      –— Œ y ­wr    )r#   )Ú.0Úlns     r   ú	<genexpr>z&LogFormatter.format.<locals>.<genexpr>Ò   s   è ø€ ÒQ¨rœ r×*ÑQùs   ‚ú
z
    )Ú
getMessageÚ
isinstancer   r#   Úmessager   Ú__dict__Ú
formatTimer   Ústrr-   ÚasctimerA   r:   r/   r>   Ú	end_colorr9   Úexc_infoÚexc_textÚformatExceptionÚrstripÚextendÚsplitÚjoinÚreplace)r?   rD   rM   ÚeÚ	formattedÚliness         r   ÚformatzLogFormatter.format¨   sS  € ð	IØ×'Ñ'Ó)ˆGÜ˜g¤Ô7Ð7Ð7ô" +¨7Ó3ˆFŒNð Ÿ™¨´´c¸4¿<¹<Ó1HÓIˆŒà�>‰>˜TŸ\™\Ñ)ØŸ<™<¨¯©Ñ7ˆFŒLØ#Ÿ|™|ˆFÕà.0Ð0ˆFŒL˜6Ô+à—I‘I §¡Ñ/ˆ	à�?Š?Ø—?’?Ø"&×"6Ñ"6°v·±Ó"G�”Ø�?Š?ð ×%Ñ%Ó'Ð(ˆEØ�L‰LÑQ°V·_±_×5JÑ5JÈ4Ó5PÔQÔQØŸ	™	 %Ó(ˆIØ× Ñ   xÓ0Ð0øô/ ò 	IØ,¨Q¨E°°V·_±_Ð4GÐHˆF�NŠNûð	Iús   ‚2E; Å;	F&ÆF!Æ!F&)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚDEFAULT_FORMATÚDEFAULT_DATE_FORMATr6   ÚDEBUGÚINFOÚWARNINGÚERRORÚCRITICALÚDEFAULT_COLORSrP   Úboolr   Úintr8   r   r^   r   r   r   r%   r%   Q   s·   „ ñð0 n€NØ+Ðà�‰�qØ�‰�aØ�‰˜Ø�‰�qØ×Ñ˜!ð€Nð "Ø*ØØØ!/ñ2àð2ð ð2ð ð	2ð
 ð2ð �S˜#�X‘ð2ð 
ó2ðh,1˜Sð ,1 Sô ,1r   r%   ÚoptionsÚloggerc                 óÒ  — | €ddl }|j                  j                  } | j                  �| j                  j                  «       dk(  ry|€t        j                  «       }|j                  t        t        | j                  j                  «       «      «       | j                  rä| j                  }|dk(  rBt        j                  j                  | j                  | j                  | j                  d¬«      }ne|dk(  rMt        j                  j                  | j                  | j                  | j                   | j                  d¬«      }nd	d
|z  z   }t#        |«      ‚|j%                  t'        d¬«      «       |j)                  |«       | j*                  s| j*                  €L|j                  s?t        j,                  «       }|j%                  t'        «       «       |j)                  |«       yyy)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Úsizezutf-8)ÚfilenameÚmaxBytesÚbackupCountÚencodingÚtime)rr   ÚwhenÚintervalrt   ru   z.The value of log_rotate_mode option should be z"size" or "time", not "%s".F)r/   )Útornado.optionsrm   r6   Ú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)rm   rn   ÚtornadoÚrotate_modeÚchannelÚerror_messages         r   Úenable_pretty_loggingr�   ×   s§  € ð €Ûà—/‘/×)Ñ)ˆØ‡�Ð '§/¡/×"7Ñ"7Ó"9¸VÒ"CØØ€~Ü×"Ñ"Ó$ˆØ
‡O�O”GœG W§_¡_×%:Ñ%:Ó%<Ó=Ô>Ø×ÒØ×-Ñ-ˆØ˜&Ò Ü×&Ñ&×:Ñ:Ø ×0Ñ0Ø ×2Ñ2Ø#×8Ñ8Ø ð	 ;ó ‰Gð ˜FÒ"Ü×&Ñ&×?Ñ?Ø ×0Ñ0Ø×,Ñ,Ø ×4Ñ4Ø#×8Ñ8Ø ð @ó ‰Gð AØ/°+Ñ=ñ>ð ô ˜]Ó+Ð+Ø×Ñœ\°Ô6Ô7Ø×Ñ˜'Ô"à×Ò ×!6Ñ!6Ð!>ÀvÇÂä×'Ñ'Ó)ˆØ×Ñœ\›^Ô,Ø×Ñ˜'Õ"ð	 HWÐ!>r   c                 óð  ‡ — ‰ €ddl }|j                  j                  Š ‰ j                  dddd¬«       ‰ j                  dt        dd	¬
«       ‰ j                  dt        ddd¬«       ‰ j                  dt
        dd¬
«       ‰ j                  dt
        dd¬
«       ‰ j                  dt        dd¬
«       ‰ j                  dt
        dd¬
«       ‰ j                  dt        dd¬
«       ‰ j                  ˆ fd„«       y)aB  Add 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.
    Nr   r6   ÚinfozSSet the Python log level. If 'none', tornado won't touch the logging configuration.zdebug|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”   r~   Ú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”   r‚   i áõz%max size of log files before rolloverrƒ   é
   znumber 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 rotatingr   rq   z(The mode of rotating files(time or size)c                  ó   •— t        ‰ «      S r    )r�   )rm   s   €r   ú<lambda>z(define_logging_options.<locals>.<lambda>W  s   ø€ Ô'<¸WÓ'E€ r   )ry   rm   Údefinerk   rP   rl   Úadd_parse_callback)rm   rŒ   s   ` r   Údefine_logging_optionsrž   	  s.  ø€ ð €ãà—/‘/×)Ñ)ˆØ‡N�NØØð%ð 0ð ô ð ‡N�NØÜØð.ð ô 	ð ‡N�NØÜØØð'ð ô ð ‡N�NØÜØ!Ø4ð	 ô ð ‡N�NØ¤S°"Ð;Xð ô ð ‡N�NØÜØð<ð ô ð ‡N�NØÜØØ3ð	 ô ð ‡N�NØÜØØ7ð	 ô ð ×ÑÓEÕFr   )NNr    )rb   r6   Úlogging.handlersr   Útornado.escaper   Útornado.utilr   r   r   ÚImportErrorr   Útypingr   r   r   r	   r{   Ú
access_logÚapp_logÚgen_logrk   r   rP   r#   r7   r%   ÚLoggerr�   rž   r   r   r   ú<module>r¨      s  ðñó Û Û 
å #ß 6ðÛðÛ÷ -Ó ,ð ˆW×ÑÐ/Ó0€
Ø
ˆ'×
Ñ
Ð1Ó
2€Ø
ˆ'×
Ñ
Ð-Ó
.€ð ó ð&�Sð ˜Só ôC1�7×$Ñ$ô C1ðN =Añ/#Øð/#Ø!)¨'¯.©.Ñ!9ð/#à	ó/#ñdNG Cð NG°4ô NGøðE ò Ø‚Hðûð
 ò Ø‚Fðús"   žB/ £B< Â/B9Â8B9Â<CÃC