PNG  IHDR;IDATxܻn0K )(pA 7LeG{ §㻢|ذaÆ 6lذaÆ 6lذaÆ 6lom$^yذag5bÆ 6lذaÆ 6lذa{ 6lذaÆ `}HFkm,mӪôô! x|'ܢ˟;E:9&ᶒ}{v]n&6 h_tڠ͵-ҫZ;Z$.Pkž)!o>}leQfJTu іچ\X=8Rن4`Vwl>nG^is"ms$ui?wbs[m6K4O.4%/bC%t Mז -lG6mrz2s%9s@-k9=)kB5\+͂Zsٲ Rn~GRC wIcIn7jJhۛNCS|j08yiHKֶۛkɈ+;SzL/F*\Ԕ#"5m2[S=gnaPeғL lذaÆ 6l^ḵaÆ 6lذaÆ 6lذa; _ذaÆ 6lذaÆ 6lذaÆ RIENDB`  oYh @sdZddlZddlZddlZddlZddlZddlZddlZddlZyddl Z ddl Z Wne k rdZ YnXddl mZmZdZejZdaddddZdd Zd d Zd d ZddZddZddZejdejZddZGdddeZ Gddde!e Z"Gddde#e Z$Gddde%e Z&Gdd d eZ'Gd!d"d"e'Z(e(Z)d#d$Z*edd%d&Z+d'd(Z,dS))a Configuration functions for the logging package for Python. The core package is based on PEP 282 and comments thereto in comp.lang.python, and influenced by Apache's log4j system. Copyright (C) 2001-2014 Vinay Sajip. All Rights Reserved. To use, simply 'import logging' and log away! N)ThreadingTCPServerStreamRequestHandleriF#Tc Csddl}t||jr'|}n;|j|}t|drU|j|n |j|t|}tj z@tj j tj dd=t ||}t|||WdtjXdS)aD Read the logging configuration from a ConfigParser-format file. This can be called several times from an application, allowing an end user the ability to select from various pre-canned configurations (if the developer provides a mechanism to present the choices and load the chosen configuration). rNreadline) configparser isinstanceZRawConfigParser ConfigParserhasattrZ read_fileread_create_formatterslogging _acquireLock _handlersclear _handlerList_install_handlers_install_loggers _releaseLock)Zfnamedefaultsdisable_existing_loggersrcp formattershandlersr%/opt/python35/lib/python3.5/config.py fileConfig8s      rc Cs|jd}|jd}t|}x]|D]U}|d|}yt||}Wq1tk rt|t||}Yq1Xq1W|S)z)Resolve a dotted name to a global object..r)splitpop __import__getattrAttributeError)nameusedfoundnrrr_resolveZs    r%cCstdd|S)NcSs |jS)N)strip)xrrrisz_strip_spaces..)map)Zalistrrr _strip_spaceshsr*c Cs|dd}t|siS|jd}t|}i}x|D]}d|}|j|ddddd }|j|d dddd }|j|d dddd }tj}||jd } | rt| }||||} | ||           rcCsdtj}xT|D]L}|jj|}||krStj|_g|_d|_q||_qWdS)a When (re)configuring logging, handle loggers which were in the previous configuration but are not in the new configuration. There's no point deleting them as other threads may continue to hold references to them; and by disabling them, you stop them doing any logging. However, don't disable children of named loggers, as that's probably not what was intended by the user. Also, allow existing loggers to NOT be disabled if disable_existing is false. TN) r rootmanager loggerDictNOTSETr@r propagatedisabled)existing child_loggersdisable_existingrQlogloggerrrr_handle_existing_loggerss      r\cCs|dd}|jd}ttdd|}|jd|d}tj}|}d|kr|d}|j|x(|jd d D]}|j|qW|d } t | r| jd} t | } x| D]} |j || qWt|j j j} | jg} x|D]}|d |}|d } |jd dd}tj| }| | kr| j| d}| d}t |}t | }xE||kr| |d ||kr| j| ||d7}qW| j| d|kr)|d}|j|x(|jd d D]}|j|q=W||_d|_|d } t | r.| jd} t | } x| D]} |j || qWq.Wt| | |d S)zCreate and install loggersloggersr+r,cSs |jS)N)r&)r'rrrr(sz"_install_loggers..rQZ logger_rootr@Nrz logger_%squalnamerUr/rr)rlistr)remover rQrEr removeHandlerr4r* addHandlerrRrSr+sortZgetint getLoggerindexrIrUrVr\)rrrYZllistrLrQrZr@rOrJrKrWrXZqnrUr[iprefixedpflen num_existingrrrrsd                            rz^[a-z_][a-z0-9_]*$cCs)tj|}|s%td|dS)Nz!Not a valid Python identifier: %rT) IDENTIFIERmatch ValueError)smrrr valid_identsrpc@s1eZdZdZdddZddZdS)ConvertingMixinz?For ConvertingXXX's, this mixin class provides common functionsTcCs_|jj|}||k r[|r.|||[a-z]+)://(?P.*)$z ^\s*(\w+)\s*z^\.\s*(\w+)\s*z^\[\s*(\w+)\s*\]\s*z^\d+$ext ext_convertZcfg cfg_convertcCst||_||j_dS)N)ruconfigrr)rzrrrr__init__nszBaseConfigurator.__init__c Cs|jd}|jd}yz|j|}x`|D]X}|d|7}yt||}Wq7tk r|j|t||}Yq7Xq7W|SWn]tk rtjdd\}}td||f}|||_ |_ |YnXdS)z` Resolve strings to objects using standard import and attribute syntax. rrr_NzCannot resolve %r: %s) rrimporterrr ImportErrorsysexc_inform __cause__ __traceback__) rzrnr!r"r#Zfragetbvrrrresolvers"    zBaseConfigurator.resolvecCs |j|S)z*Default converter for the ext:// protocol.)r)rzr{rrrrszBaseConfigurator.ext_convertc CsY|}|jj|}|dkr7td|n||jd}|j|jd}x|rT|jj|}|r||jd}n|jj|}|r|jd}|jj|s||}n9yt |}||}Wnt k r||}YnX|r;||jd}qgtd||fqgW|S)z*Default converter for the cfg:// protocol.NzUnable to convert %rrzUnable to convert %r at %r) WORD_PATTERNrlrmendrgroups DOT_PATTERN INDEX_PATTERN DIGIT_PATTERNint TypeError)rzr{restrodrr$rrrrs2     zBaseConfigurator.cfg_convertcCs&t|t r7t|tr7t|}||_nt|t rnt|trnt|}||_nt|t rt|trt|}||_n}t|tr"|j j |}|r"|j }|d}|j j |d}|r"|d}t||}||}|S)z Convert values to an appropriate type. dicts, lists and tuples are replaced by their converting alternatives. Strings are checked to see if they have a conversion format and are converted if they do. prefixNsuffix)rrurrrrvr`rwrstrCONVERT_PATTERNrl groupdictvalue_convertersr5r)rzr{rorr converterrrrrrss*          zBaseConfigurator.convertcsjd}t|s*|j|}jdd}tfddD}||}|rx*|jD]\}}t|||qzW|S)z1Configure an object with a user-supplied factory.z()rNcs,g|]"}t|r||fqSr)rp).0k)rrr s z5BaseConfigurator.configure_custom..)rcallablerritemssetattr)rzrr:propskwargsr}r!r{r)rrconfigure_customs  z!BaseConfigurator.configure_customcCst|trt|}|S)z0Utility function which converts lists to tuples.)rr`r)rzr{rrras_tuples zBaseConfigurator.as_tupleN)rrrrrecompilerrrrrr staticmethodrrrrrrrsrrrrrrrZs       "  rc@seZdZdZddZddZddZdd Zd d Zd d Z dddZ dddZ dddZ dS)DictConfiguratorz] Configure logging using a dictionary-like object to describe the configuration. cCs<|j}d|kr!td|ddkrEtd|d|jdd}i}tjz|r|jd|}x|D]}|tjkrtd|qyItj|}||}|jd d }|r|jtj|Wqt k r7} ztd || fWYd d } ~ XqXqW|jd |} xg| D]_}y|j || |d WqUt k r} ztd|| fWYd d } ~ XqUXqUW|jdd } | r)y|j | d Wq)t k r} ztd| WYd d } ~ Xq)Xn |jdd } tjj tj d d =|jd|} xg| D]_}y|j| || |)rr5r Filter)rzrr}r!rrrrs  z!DictConfigurator.configure_filtercCsoxh|D]`}y|j|jd|Wqtk rf}ztd||fWYdd}~XqXqWdS)z/Add filters to a filterer from a list of names.rzUnable to add filter %r: %sN) addFilterrrrm)rzZfiltererrr<rrrr add_filterss  zDictConfigurator.add_filtersc/sDt}jdd}|rwy|jd|}Wn;tk rv}ztd||fWYdd}~XnXjdd}jdd}dkrjd}t|s|j|}|}nKjd} |j| } t| tj j rd kryN|jd d } t | tj s\j |td | d .z'stream'streamZstrm)rrrrrmrrrGr rrHrHandlerupdaterZ SMTPHandlerrZ SysLogHandlerrrFrErrrr)rzrZ config_copyr=rr@rr:rrrMthrrr}rr!r{r)rrrsl #      *    z"DictConfigurator.configure_handlercCsoxh|D]`}y|j|jd|Wqtk rf}ztd||fWYdd}~XqXqWdS)z.Add handlers to a logger from a list of names.rzUnable to add handler %r: %sN)rcrrrm)rzr[rrOrrrr add_handlerss  zDictConfigurator.add_handlersFcCs|jdd}|dk r4|jtj||sx(|jddD]}|j|qNW|jdd}|r|j|||jdd}|r|j||dS)zU Perform configuration which is common to root and non-root loggers. r@Nrr)r5rEr rrrbrr)rzr[rrr@rOrrrrrcommon_logger_configs z%DictConfigurator.common_logger_configcCsMtj|}|j||||jdd}|dk rI||_dS)z.Configure a non-root logger from a dictionary.rUN)r rerr5rU)rzr!rrr[rUrrrr s  z!DictConfigurator.configure_loggercCs#tj}|j|||dS)z*Configure a root logger from a dictionary.N)r rer)rzrrrQrrrrs zDictConfigurator.configure_rootN) rrrrrrrrrrrrrrrrrrs    ? rcCst|jdS)z%Configure logging using a dictionary.N)dictConfigClassr)rrrr dictConfigsrcsptstdGdddt}Gdddt}Gfdddtj||||S)au Start up a socket server on the specified port, and listen for new configurations. These will be sent as a file suitable for processing by fileConfig(). Returns a Thread object on which you can call start() to start the server, and which you can join() when appropriate. To stop the server, call stopListening(). Use the ``verify`` argument to verify any bytes received across the wire from a client. If specified, it should be a callable which receives a single argument - the bytes of configuration data received across the network - and it should return either ``None``, to indicate that the passed in bytes could not be verified and should be discarded, or a byte string which is then passed to the configuration machinery as normal. Note that you can return transformed bytes, e.g. by decrypting the bytes passed in. z listen() needs threading to workc@s"eZdZdZddZdS)z#listen..ConfigStreamHandlerz Handler for a logging configuration request. It expects a completely new logging configuration and uses fileConfig to install it. cSsya|j}|jd}t|dkr`tjd|d}|jj|}x3t||kr||j|t|}qXW|jjdk r|jj|}|dk rD|jd}y)ddl}|j |}t |WnNt k rCt j |}yt|Wnt k r>tjYnXYnX|jjr`|jjjWn7tk r}z|jtkrWYdd}~XnXdS)z Handle a request. Each request is expected to be a 4-byte length, packed using struct.pack(">L", n), followed by the config file. Uses fileConfig() to do the grunt work. z>LrNzutf-8) connectionrecvr4structunpackserververifydecodejsonloadsrrioStringIOr traceback print_excreadysetOSErrorerrno RESET_ERROR)rzconnchunkZslenrrfilerrrrhandle;s6 !     z*listen..ConfigStreamHandler.handleN)rrrrrrrrrConfigStreamHandler4s rc@sCeZdZdZdZdedddddZddZdS) z$listen..ConfigSocketReceiverzD A simple TCP socket-based logging config receiver. r_ localhostNcSsUtj|||f|tjd|_tjd|_||_||_dS)Nrr_) rrr r abortrtimeoutrr)rzhostportrrrrrrris     z-listen..ConfigSocketReceiver.__init__cSsddl}d}xg|s{|j|jjggg|j\}}}|r[|jtj|j}tjqW|jj dS)Nr) selectsocketfilenorZhandle_requestr r rrclose)rzrrZrdwrexrrrserve_until_stoppedss     z8listen..ConfigSocketReceiver.serve_until_stopped)rrrrZallow_reuse_addressDEFAULT_LOGGING_CONFIG_PORTrrrrrrConfigSocketReceiverbs  rcs1eZdZfddZddZS)zlisten..ServercsJt|j||_||_||_||_tj|_dS)N) superrrcvrhdlrrr threadingEventr)rzrrrr)Server __class__rrrs     zlisten..Server.__init__c Ss|jd|jd|jd|jd|j}|jdkrO|jd|_|jjtj|a tj |j dS)Nrrrrrr_) rrrrrZserver_addressrr r _listenerrr)rzrrrrruns     zlisten..Server.run)rrrrrr)r)rrrs r)threadNotImplementedErrorrrrThread)rrrrr)rrlistens  .rc Cs5tjztr"dt_daWdtjXdS)zN Stop the listening server which was created with a call to listen(). r_N)r r rrrrrrr stopListenings    r)-rrrr Zlogging.handlersrrrr_threadrrr socketserverrrrZ ECONNRESETrrrr%r*r rr\rrIrkrpobjectrqrrur`rvrrwrrrrrrrrrrsJ            "    #  V ! 9 |