"Tes. ddlZddlmZddlmZmZddlmZddlmZddlm Z m Z m Z m Z m Z mZddlmZdd lmZdd lmZmZdd lmZmZdd lmZmZdd lmZddlmZGddeZ e!dk(ruddl"m#Z#dZ$ejJde$de ddgejLdZ'e'jQde'jQde#de'jQde'jQde'jQde'jSde#de'jUd d!d"gd#d$gd%d&d!ddd%d'e'jUd(e'jWd)e'jQd*e'jQd+e'jSd,d3d-Z,e,e#de'j[d.e'jQd/e'jQd0e.d12yy)4N)datetime)Handler LogRecord)Path) ModuleType)ClassVarIterableListOptionalTypeUnion)NullFile) get_console)FormatTimeCallable LogRender)ConsoleConsoleRenderable) HighlighterReprHighlighter)Text) Tracebackc,eZdZUdZgdZeeeee d<e Z ee e e d<ejdfdddddddddddddd d d d dd deeefdeededededededee dededeededeedededeeeefdeded eeefd!eeed"df*fd#Zd$ed"efd%Zd$ed"dfd&Zd$ed'ed"d(fd)Zd$ed*eed+d(d"d(fd,ZxZS)- RichHandlera A logging handler that renders output with Rich. The time / level / message and file are displayed in columns. The level is color coded, and the message is syntax highlighted. Note: Be careful when enabling console markup in log messages if you have configured logging for libraries not under your control. If a dependency writes messages containing square brackets, it may not produce the intended output. Args: level (Union[int, str], optional): Log level. Defaults to logging.NOTSET. console (:class:`~rich.console.Console`, optional): Optional console instance to write logs. Default will use a global console instance writing to stdout. show_time (bool, optional): Show a column for the time. Defaults to True. omit_repeated_times (bool, optional): Omit repetition of the same time. Defaults to True. show_level (bool, optional): Show a column for the level. Defaults to True. show_path (bool, optional): Show the path to the original log call. Defaults to True. enable_link_path (bool, optional): Enable terminal link of path column to file. Defaults to True. highlighter (Highlighter, optional): Highlighter to style log messages, or None to use ReprHighlighter. Defaults to None. markup (bool, optional): Enable console markup in log messages. Defaults to False. rich_tracebacks (bool, optional): Enable rich tracebacks with syntax highlighting and formatting. Defaults to False. tracebacks_width (Optional[int], optional): Number of characters used to render tracebacks, or None for full width. Defaults to None. tracebacks_extra_lines (int, optional): Additional lines of code to render tracebacks, or None for full width. Defaults to None. tracebacks_theme (str, optional): Override pygments theme used in traceback. tracebacks_word_wrap (bool, optional): Enable word wrapping of long tracebacks lines. Defaults to True. tracebacks_show_locals (bool, optional): Enable display of locals in tracebacks. Defaults to False. tracebacks_suppress (Sequence[Union[str, ModuleType]]): Optional sequence of modules or paths to exclude from traceback. locals_max_length (int, optional): Maximum length of containers before abbreviating, or None for no abbreviation. Defaults to 10. locals_max_string (int, optional): Maximum length of string before truncating, or None to disable. Defaults to 80. log_time_format (Union[str, TimeFormatterCallable], optional): If ``log_time`` is enabled, either string for strftime or callable that formats the time. Defaults to "[%x %X] ". keywords (List[str], optional): List of words to highlight instead of ``RichHandler.KEYWORDS``. )GETPOSTHEADPUTDELETEOPTIONSTRACEPATCHKEYWORDSHIGHLIGHTER_CLASSNTF Pz[%x %X]) show_timeomit_repeated_times show_level show_pathenable_link_path highlightermarkuprich_tracebackstracebacks_widthtracebacks_extra_linestracebacks_themetracebacks_word_wraptracebacks_show_localstracebacks_suppresslocals_max_lengthlocals_max_stringlog_time_formatkeywordslevelconsoler)r*r+r,r-r.r/r0r1r2r3r4r5r6r7r8r9r:returncRt|||xs t|_|xs|j |_t |||||d|_||_| |_ | |_ | |_ | |_ | |_ ||_||_||_||_||_||_y)N)r;)r)r+r, time_formatr* level_width)super__init__rr<r$r.r _log_renderr-r/r0r1r2r3r4r5r6r7r8r:)selfr;r<r)r*r+r,r-r.r/r0r1r2r3r4r5r6r7r8r9r: __class__s ./usr/lib/python3/dist-packages/rich/logging.pyrBzRichHandler.__init__?s0 u%/+- &B$*@*@*B$!' 3  !1 . 0&<# 0$8!&<##6 !2!2  recordc|j}tj|jdd|j }|S)zGet the level name from the record. Args: record (LogRecord): LogRecord instance. Returns: Text: A tuple of the style and level name. zlogging.level.) levelnamerstyledljustlower)rDrH level_name level_texts rFget_level_textzRichHandler.get_level_textosF%% [[   Q >*2B2B2D1E!F rGc |j|}d}|jr0|jr#|jdk7r|j\}}}|J|Jtj||||j |j |j|j|j|j|j|j }|j}|jro|j|_|j}t!|dr1|j#r!|j%||j&|_|j+|}|j-||}|j/|||} t1|j2j4t6r|j9|y |j2j;| y#t<$r|j9|YywxYw)zInvoked by logging.N)NNN)width extra_linestheme word_wrap show_localsr7r8suppressusesTime)rH tracebackmessage_renderable)formatr0exc_inforfrom_exceptionr1r2r3r4r5r7r8r6 getMessage formattermessagehasattrrY formatTimedatefmtasctime formatMessagerender_messagerender isinstancer<filer handleErrorprint Exception) rDrHrarZexc_type exc_value exc_tracebackr`r[log_renderables rFemitzRichHandler.emit~s++f%  #5517 .Hi' ''( ((!00++ 77++33 77"&"8"8"&"8"811 I'')G~~!'!2!2!4 NN 9j1i6H6H6J%.%9%9&)BSBS%TFN#11&9!00AYCU%  dll'' 2   V $ ) "">2 )  ( )s.G G'&G'rarcDt|d|j}|rtj|n t|}t|d|j}|r||}|j |j |_|j r|j|j d|S)zRender message text in to Text. Args: record (LogRecord): logging Record. message (str): String containing log message. Returns: ConsoleRenderable: Renderable to display log message. r/r.zlogging.keyword)getattrr/r from_markupr.r:r#highlight_words)rDrHra use_markup message_textr.s rFrgzRichHandler.render_messagesVXt{{; 4>t''0DM fmT5E5EF &|4L ==  MMDM ==  ( (8I JrGrZr[c t|jj}|j|}|jdn|jj }t j|j}|j|j|s|gn||g|||||j|jr |jnd}|S)avRender log for display. Args: record (LogRecord): logging Record. traceback (Optional[Traceback]): Traceback instance or None for no Traceback. message_renderable (ConsoleRenderable): Renderable (typically Text) containing log message contents. Returns: ConsoleRenderable: Renderable to display log. N)log_timer?r;pathline_no link_path) rpathnamenamerQr`rdr fromtimestampcreatedrCr<linenor-) rDrHrZr[r{r;r?rzrqs rFrhzRichHandler.renders"FOO$))##F+"nn4d$..:P:P ))&..9)) LL(1  8JI7V#MM)-)>)>fooD*  rG) __name__ __module__ __qualname____doc__r#rr r str__annotations__rr$r rloggingNOTSETr intrboolr rrrBrrrQrrrgrrh __classcell__)rEs@rFrrs @ /HhxS *+ 6Ex[ 12D")%).! $(!%-1 %*.&'*.%)',@B!#!#:C(,-.!S#X.!'".!  .! " .!.!.!.!k*.!.!.!#3-.!!$.!#3-.! #!.!"!%#.!$&eCO&<=%.!&'.!().!*s$667+.!,49%-.!. /.!` Y 4 .)9.).)`YAT2  I&  0   rGr__main__)sleepz %(message)srz[%X]T)r0r5)r;r\rdhandlersrichzServer starting...z"Listening on http://127.0.0.1:8080zGET /index.html 200 1298z)GET /imgs/backgrounds/back1.jpg 200 54386zGET /css/styles.css 200 54386zGET /favicon.ico 404 242zJSONRPC request --> %r <-- %rz1.1confirmFruitPurchase)appleorangemangoespomelog+? 194521489)versionmethodparamsid)rresulterrorrzrLoading configuration file /adasd/asdasd/qeqwe/qwrqwrqwr/sdgsdgsdg/werwerwer/dfgerert/ertertert/ertetert/werwerwerz$Unable to find 'pomelo' in database!zPOST /jsonrpc/ 200 65532zPOST /admin/ 401 42234z%password was rejected for admin site.cd}d}dgdz}tjd ||z y#tjdYyxYw)Nrrfoodz in dividezAn error of some kind occurred!)logdebug exception)numberdivisorfooss rFdividersDw} + = W  = MM; rs&BB$6/5 U'Up z FGd4PQ  '  F #CHH !"HH 12 !HHH '(HH 89HH ,-KK*+ !HII),?G  TD L II|II45HH '(HH %&KK78= H !HLL!"HH )*HH &d$.?H@orG