K i1dZddlZddlZddlZddlmZddlmZmZ ddl Z ddl Z ddl m Z mZmZmZej"dZej"dZej"dZd efd Zd ed efd ZGd dej2Z ddedeej6d dfdZdded dfdZy#e $rdZ YwxYw#e $rdZ YwxYw)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_typebasestring_type)DictAnycastOptionalztornado.accessztornado.applicationztornado.generalreturncn ttjdrtjjrmtr-t j t j ddkDr;ytr4tjttjdturyy#t$rYywxYw)NisattycolorsrTwrapped_stderrF) hasattrsysstderrr curses setuptermtigetnumcoloramagetattr initialiseobject ExceptionQ/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/tornado/log.py_stderr_supports_colorr7s 3::x (SZZ->->-@  "??8,q0::'')968"      sA*B(-9B(( B43B4scN t|S#t$rt|cYSwxYwN)rUnicodeDecodeErrorrepr)rs r _safe_unicoder#Js){ Aws $$c eZdZdZdZdZejdejdejdejdejdiZ eed d e fd e d e d e dedeeefddf dZdede fdZy) 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%Tfmtdatefmtstylecolorr r NcDtjj||||_i|_|rt rt t jdxst jdxsd}|jD]2\}}tt j||d|j|<4t jd} | t| d|_ yd|_ y|jD]\}}d |z|j|<d |_ yd|_ 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-Nsetafsetfrasciisgr0z[2;3%dmz) logging Formatter__init___fmt_colorsrrtigetstritemsrtparm_normal) selfr,r-r.r/r fg_colorlevelnocodenormals rr8zLogFormatter.__init__ts. ""4"9  +-!!??73Uvv7NURU%+\\^MGT-9 Xt4g-DLL)  0%#/#@DL#%DL&,\\^AMGT,9D,@DLL)A( DLrrecordcR |j}t|tsJt||_|j|tt|j|_ |j|jvr0|j|j|_|j|_ndx|_|_|j"|j z}|j$r,|j&s |j)|j$|_|j&rS|j+g}|j-d|j&j/dDdj1|}|j3ddS#t $r"}d|d|j |_Yd}~md}~wwxYw)Nz Bad message (z): r5c32K|]}t|ywr )r#).0lns r z&LogFormatter.format..sQrr*Qs z ) getMessage isinstancerr#messager__dict__ formatTimerstrr-asctimerAr:r/r> end_colorr9exc_infoexc_textformatExceptionrstripextendsplitjoinreplace)r?rDrMe formattedliness rformatzLogFormatter.formatsS I'')Gg7 77"+73FNc4<<1HI >>T\\ )<<7FL#||F .0 0FL6+II/ ????"&"6"6v"G ??%%'(E LLQV__5J5J45PQ Q %(I  x00/ I,QEV__4GHFNN Is2E;; F&F!!F&)__name__ __module__ __qualname____doc__DEFAULT_FORMATDEFAULT_DATE_FORMATr6DEBUGINFOWARNINGERRORCRITICALDEFAULT_COLORSrPboolrintr8rr^rrrr%r%Qs0nN+ q a q! N"*!/ 2 22 2  2 S#X 2 2h,1S,1S,1rr%optionsloggerc|ddl}|jj}|j|jjdk(ry|tj}|j t t|jj|jr|j}|dk(rBtjj|j|j|jd}ne|dk(rMtjj|j|j|j |jd}nd d |zz}t#||j%t'd |j)||j*s|j*L|js?tj,}|j%t'|j)|yyy) zTurns on formatted logging output as configured. This is called automatically by `tornado.options.parse_command_line` and `tornado.options.parse_config_file`. Nrnonesizezutf-8)filenamemaxBytes backupCountencodingtime)rrwhenintervalrtruz.The value of log_rotate_mode option should be z"size" or "time", not "%s".F)r/)tornado.optionsrmr6lower getLoggersetLevelrupperlog_file_prefixlog_rotate_modehandlersRotatingFileHandlerlog_file_max_sizelog_file_num_backupsTimedRotatingFileHandlerlog_rotate_whenlog_rotate_interval ValueError setFormatterr% addHandler log_to_stderr StreamHandler)rmrntornado rotate_modechannel error_messages renable_pretty_loggingrs//))'//"7"7"9V"C ~""$ OOGGW__%:%:%<=>-- & &&:: 00 22#88 ;G F "&&?? 00,, 44#88 @GA/+=> ]+ +\67'"!6!6!>v'')\^,'" HW!>rcddl}|jjjddddjdtdd jd tdd d jdt dd jdt dd jdtdd jdt dd jdtdd j fdy)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. Nrr6infozSSet the Python log level. If 'none', tornado won't touch the logging configuration.zdebug|info|warning|error|none)defaulthelpmetavarrzSend log output to stderr (colorized if possible). By default use stderr if --log_file_prefix is not set and no other logging is configured.)typerrr~PATHzPath 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))rrrrriz%max size of log files before rolloverr znumber of log files to keeprmidnightzcspecify the type of TimedRotatingFileHandler interval other options:('S', 'M', 'H', 'D', 'W0'-'W6')rr)z$The interval value of timed rotatingrrqz(The mode of rotating files(time or size)ctSr )r)rmsrz(define_logging_options..Ws 'rs #6-,W  / 0 '  1 2 '  - .&SSC17$$C1N=A/# /#!)'..!9/# /#dNGCNG4NGEH  Fs"B/B</B98B9<CC