\d; dZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl m Z ddl mZddl mZgdZddlZdZdZd Zd ZejZd Zd Zd Zd Zd ZeZd ZdZeZ dZ!dZ"dZ#ededede!de"de#diZ$eeeeee!e"e#dZ%dZ&dZ'dZ(e)edrdZ*ndZ*ej+,e(j-j.Z/dZ0dZ1ej2Z3d Z4d!Z5e)ed"sd#Z6n(ej7Z8d$Z6d%Z9ej:e4e9e5&Gd'd(e;Zd*Z?d+Z@eZA[Gd,d-e;ZBGd.d/eBZCGd0d1eBZDd2ZEeBeEfeCd3feDd4fd5ZFGd6d7e;ZeZGGd8d9e;ZHGd:d;e;ZIGd<d=e;ZJejKZLgZMd>ZNd?ZOGd@dAeJZPGdBdCePZQGdDdEeQZRGdFdGeQZSeSeZTeTZUGdHdIe;ZVdJZWdKZXGdLdMe;ZYGdNdOeJZZGdPdQeZZ[eZa\GdRdSe;Z]e[eZ^e^eZ_^eYeZj^eZ__dTZ`dfdUZadVZbdWZcdXZdd dYdZZed[Zfd\Zgd]Zhd^Zid_Zjefd`ZkeMfdaZlddlmZmemjnelGdbdcePZodapdgddZqdeZrdS)hz Logging package for Python. Based on PEP 282 and comments thereto in comp.lang.python. Copyright (C) 2001-2019 Vinay Sajip. All Rights Reserved. To use, simply 'import logging' and log away! N) GenericAlias)Template) Formatter)+ BASIC_FORMATBufferingFormatterCRITICALDEBUGERRORFATAL FileHandlerFilterrHandlerINFO LogRecordLogger LoggerAdapterNOTSET NullHandler StreamHandlerWARNWARNING addLevelName basicConfigcaptureWarningscriticaldebugdisableerror exceptionfatal getLevelName getLoggergetLoggerClassinfolog makeLogRecordsetLoggerClassshutdownwarnwarninggetLogRecordFactorysetLogRecordFactory lastResortraiseExceptionsgetLevelNamesMappingz&Vinay Sajip productionz0.5.1.2z07 February 2010T2( rr rrr r)rr r rrrr rc4tSN) _nameToLevelcopy!..\python\lib\logging\__init__.pyr/r/xs     r;ct|}||St|}||Sd|zS)a Return the textual or numeric representation of logging level 'level'. If the level is one of the predefined levels (CRITICAL, ERROR, WARNING, INFO, DEBUG) then you get the corresponding string. If you have associated levels with names using addLevelName then the name you have associated with 'level' is returned. If a numeric value corresponding to one of the defined levels is passed in, the corresponding string representation is returned. If a string representation of the level is passed in, the corresponding numeric value is returned. If no matching numeric or string value is passed in, the string 'Level %s' % level is returned. NzLevel %s) _levelToNamegetr8)levelresults r<r!r!{sK&  e $ $F    e $ $F   r;ct |t|<|t|<tdS#twxYw)zy Associate 'levelName' with 'level'. This is used when converting levels to text during message formatting. N) _acquireLockr>r8 _releaseLock)r@ levelNames r<rrsA NNN' U"' Y s 4A _getframec*tjdS)N)sysrFr:r;r<rJs3=++r;cx t#t$r&tjdjjcYSwxYw)z5Return the frame object for the caller's stack frame.) ExceptionrIexc_infotb_framef_backr:r;r< currentframerQsD 5O 5 5 5<>>!$-4 4 4 4 5s  -99cztj|jj}|t kpd|vod|vS)zASignal whether the frame is a CPython or logging module internal. importlib _bootstrap)ospathnormcasef_code co_filename_srcfile)framefilenames r<_is_internal_framer]s@w 899H x  x)rrrrrrs r<__repr__zLogRecord.__repr__ls848IIIt||| MMM4;;;2 2r;cPt|j}|jr ||jz}|S)z Return the message for this LogRecord. Return the message for this LogRecord after merging any user-supplied arguments with the message. )rarr)rrs r< getMessagezLogRecord.getMessageps+$(mm 9 " /C r;NN)__name__ __module__ __qualname____doc__rrrr:r;r<rrsZ  8<F F F F P222     r;rc |adS)z Set the factory to be used when instantiating a log record. :param factory: A callable which will be called to instantiate a log record. N_logRecordFactory)factorys r<r,r,s r;ctS)zH Return the factory to be used when instantiating a log record. rr:r;r<r+r+s r;c ftdddddddd}|j||S)z Make a LogRecord whose attributes are defined by the specified dictionary, This function is useful for converting a logging event received over a socket connection (which is sent as a dictionary) into a LogRecord instance. Nrr:)r__dict__update)dictrds r<r&r&s: 4r1b"dD A ABKt Ir;cjeZdZdZdZdZejdejZ dddZ dZ d Z d Z d ZdS) PercentStylez %(message)sz %(asctime)sz %(asctime)z5%\(\w+\)[#0+ -]*(\*|\d+)?(\.(\*|\d+))?[diouxefgcrsa%]Ndefaultsc0|p|j|_||_dSr7)default_format_fmt _defaults)rfmtrs r<rzPercentStyle.__init__s.4. !r;cH|j|jdkS)Nrrfindasctime_searchrs r<usesTimezPercentStyle.usesTimesy~~d122a77r;c|j|js&td|jd|jdddS)z>Validate the input format, ensure it matches the correct stylezInvalid format 'z' for 'rz' styleN)validation_patternsearchrrbrrs r<validatezPercentStyle.validatesU&--di88 i*TYYYPTPcdePfPfPfghh h i ir;cL|jx}r ||jz}n|j}|j|zSr7)rrrrrecordrvaluess r<_formatzPercentStyle._formats3~ %8 %/FF_Fy6!!r;cv ||S#t$r}td|zd}~wwxYw)Nz(Formatting field not found in record: %s)rKeyErrorrb)rres r<formatzPercentStyle.formatsQ M<<'' ' M M MG!KLL L Ms 838)rrrrasctime_formatrrecompileIrrrrrrr:r;r<rrs"N"N!N#$\^`^bcc(,"""""888iii """MMMMMr;rcreZdZdZdZdZejdejZ ejdZ dZ dZ dS) StrFormatStylez {message}z {asctime}z{asctimezF^(.?[<>=^])?[+ -]?#?0?(\d+|{\w+})?[,_]?(\.(\d+|{\w+}))?[bcdefgnosx%]?$z^(\d+|\w+)(\.\w+|\[[^]]+\])*$c\|jx}r ||jz}n|j}|jjdi|SNr:)rrrrrs r<rzStrFormatStyle._formatsA~ %8 %/FF_Fty))&)))r;ct} t|jD]\}}}}|rA|j|st d|z|||r|dvrt d|z|r,|j|st d|zn$#t $r}t d|zd}~wwxYw|st ddS)zKValidate the input format, ensure it is the correct string formatting stylez!invalid field name/expression: %rrsazinvalid conversion: %rzbad specifier: %rzinvalid format: %sNinvalid format: no fields) set_str_formatterparser field_specmatchrbrsfmt_spec)rfields_ fieldnamespec conversionrs r<rzStrFormatStyle.validates: 72@2F2Fty2Q2Q A A.9dJ*?00;;Z()Ly)XYYYJJy)))L*E"9"9$%= %JKKKA 3 3D 9 9A$%84%?@@@ A 7 7 71A566 6 7 :899 9 : :sB0C C" CC"N) rrrrrrrrrrrrrr:r;r<rrsk N NNrzcegeijjH<==J***:::::r;rc<eZdZdZdZdZfdZdZdZdZ xZ S)StringTemplateStylez ${message}z ${asctime}cltj|i|t|j|_dSr7)superrrr_tpl)rrr __class__s r<rzStringTemplateStyle.__init__s4$)&)))TY'' r;c~|j}|ddkp||jdkS)Nz$asctimerrrrs r<rzStringTemplateStyle.usesTimes9ixx ##q(NCHHT5H,I,IQ,NNr;ctj}t}||jD]}|}|dr||d:|dr||d^|ddkrtd|stddS)Nnamedbracedr$z$invalid format: bare '$' not allowedr) rpatternrfinditerr groupdictrsgrouprb)rrrmds r<rzStringTemplateStyle.validates"!!$),, K KA Az K 1W:&&&&8 K 1X;''''s"" !IJJJ# :899 9 : :r;c\|jx}r ||jz}n|j}|jjdi|Sr)rrr substituters r<rzStringTemplateStyle._formatsA~ %8 %/FF_F#ty#--f---r;) rrrrrrrrrr __classcell__)rs@r<rrsw!N!N!N(((((OOO : : :.......r;rz"%(levelname)s:%(name)s:%(message)sz{levelname}:{name}:{message}z${levelname}:${name}:${message})%{rc\eZdZdZejZddddZdZdZ dd Z d Z d Z d Z d ZdZdS)ra Formatter instances are used to convert a LogRecord to text. Formatters need to know how a LogRecord is constructed. They are responsible for converting a LogRecord to (usually) a string which can be interpreted by either a human or an external system. The base Formatter allows a formatting string to be specified. If none is supplied, the style-dependent default value, "%(message)s", "{message}", or "${message}", is used. The Formatter can be initialized with a format string which makes use of knowledge of the LogRecord attributes - e.g. the default value mentioned above makes use of the fact that the user's message and arguments are pre- formatted into a LogRecord's message attribute. Currently, the useful attributes in a LogRecord are described by: %(name)s Name of the logger (logging channel) %(levelno)s Numeric logging level for the message (DEBUG, INFO, WARNING, ERROR, CRITICAL) %(levelname)s Text logging level for the message ("DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL") %(pathname)s Full pathname of the source file where the logging call was issued (if available) %(filename)s Filename portion of pathname %(module)s Module (name portion of filename) %(lineno)d Source line number where the logging call was issued (if available) %(funcName)s Function name %(created)f Time when the LogRecord was created (time.time() return value) %(asctime)s Textual time when the LogRecord was created %(msecs)d Millisecond portion of the creation time %(relativeCreated)d Time in milliseconds when the LogRecord was created, relative to the time the logging module was loaded (typically at application startup time) %(thread)d Thread ID (if available) %(threadName)s Thread name (if available) %(process)d Process ID (if available) %(message)s The result of record.getMessage(), computed just as the record is emitted NrTrc:|tvr>> LLNN RSS6T>>#2#Ar;c4|jS)zK Check if the format uses the creation time of the record. )rrrs r<rzFormatter.usesTimes{##%%%r;c6|j|Sr7)rrrrs r< formatMessagezFormatter.formatMessages{!!&)))r;c|S)aU This method is provided as an extension point for specialized formatting of stack information. The input data is a string as returned from a call to :func:`traceback.print_stack`, but with the last trailing newline removed. The base implementation just returns the value passed in. r:)rrs r< formatStackzFormatter.formatStacks r;c||_|r |||j|_||}|jr&|js| |j|_|jr|dddkr|dz}||jz}|j r0|dddkr|dz}|| |j z}|S)az Format the specified record as text. The record's attribute dictionary is used as the operand to a string formatting operation which yields the returned string. Before formatting the dictionary, a couple of preparatory steps are carried out. The message attribute of the record is computed using LogRecord.getMessage(). If the formatting string uses the time (as determined by a call to usesTime(), formatTime() is called to format the event time. If there is exception information, it is formatted using formatException() and appended to the message. rNr) rmessagerrrasctimer*rNrr&rr,)rrrs r<rzFormatter.formats **,, ==?? C!__VT\BBFN   v & & ? H? H"&"6"6v"G"G ? $v~~HFO#A   8v~~HD$$V%6777Ar;)NNrTr7)rrrrr localtimerrrrrr&rr*r,rr:r;r<rrs((TI6.#6&&&& ***   r;rc,eZdZdZddZdZdZdZdS)rzB A formatter suitable for formatting a number of records. Nc4|r ||_dSt|_dS)zm Optionally specify a formatter which will be used to format each individual record. N)linefmt_defaultFormatter)rr3s r<rzBufferingFormatter.__init__s"  -"DLLL,DLLLr;cdS)zE Return the header string for the specified records. rr:rrecordss r< formatHeaderzBufferingFormatter.formatHeader rr;cdS)zE Return the footer string for the specified records. rr:r6s r< formatFooterzBufferingFormatter.formatFooterr9r;cd}t|dkrR|||z}|D]}||j|z} |||z}|S)zQ Format the specified records and return the result as a string. rr)rr8r3rr;)rr7rdrs r<rzBufferingFormatter.formatsz w<>4 Y&+ % %4 [  diDI 6 6! ; ;5 DI&#-.r;N)r)rrrrrrCr:r;r<r r sA       / / / / /r;r c*eZdZdZdZdZdZdZdS)Filtererz[ A base class for loggers and handlers which allows them to share common code. cg|_dS)zE Initialize the list of filters to be an empty list. N)filtersrs r<rzFilterer.__init__s r;cP||jvr|j|dSdS)z; Add the specified filter to this handler. N)rGappendrrCs r< addFilterzFilterer.addFilter!s5$,&& L   ' ' ' ' ''&r;cP||jvr|j|dSdS)z@ Remove the specified filter from this handler. N)rGremoverJs r< removeFilterzFilterer.removeFilter(s5 T\ ! ! L   ' ' ' ' ' " !r;cd}|jD]9}t|dr||}n ||}|sd}n:|S)ah Determine if a record is loggable by consulting all the filters. The default is to allow the record to be logged; any filter can veto this and the record is then dropped. Returns a zero value if a record is to be dropped, else non-zero. .. versionchanged:: 3.2 Allow filters to be just callables. TrCF)rGrrC)rrrdfrAs r<rCzFilterer.filter/sj  Aq(## #&))6   r;N)rrrrrrKrNrCr:r;r<rErEsZ ((((((r;rEcttt}}}|rP|rP|rP| ||n#t$rYnwxYw|dS#|wxYwdSdSdS)zD Remove a handler reference from the internal cleanup list. N)rCrD _handlerListrMrb)wrrhrjhandlerss r<_removeHandlerRefrUMs".|\hWG7x   OOB        D  GIIIIIGGIIIIs&=A A A A  A A%ct ttj|t t dS#t wxYw)zL Add a handler to the internal cleanup list using a weak reference. N)rCrRrIweakrefrefrUrDrvs r<_addHandlerRefrY_sNNNNGK1BCCDDD s 2AA"ceZdZdZefdZdZdZeeeZ dZ dZ dZ dZ d Zd Zd Zd Zd ZdZdZdZdZdS)raq Handler instances dispatch logging events to specific destinations. The base handler class. Acts as a placeholder which defines the Handler interface. Handlers can optionally use Formatter instances to format records as desired. By default, no formatter is specified; in this case, the 'raw' message as determined by record.message is logged. ct|d|_t||_d|_d|_t||dS)zz Initializes the instance - basically setting the formatter to None and the filter list to empty. NF) rEr_namerer@ formatter_closedrY createLockrr@s r<rzHandler.__init__rs` $  ''  t r;c|jSr7)r\rs r<get_namezHandler.get_names zr;ct |jtvr t|j=||_|r |t|<tdS#twxYwr7)rCr\ _handlersrDr@s r<set_namezHandler.set_namesZ zY&&dj)DJ '"& $ NNNNNLNNNNs .AAcTtj|_t|dS)zU Acquire a thread lock for serializing access to the underlying I/O. N)rRLocklockrors r<r_zHandler.createLocks'O%% %d+++++r;c8|jdSr7)rhrurs r<ruzHandler._at_fork_reinits !!#####r;cJ|jr|jdSdS)z. Acquire the I/O thread lock. N)rhrhrs r<rhzHandler.acquire2 9 I         r;cJ|jr|jdSdS)z. Release the I/O thread lock. N)rhrjrs r<rjzHandler.releaserkr;c.t||_dS)zX Set the logging level of this handler. level must be an int or a str. N)rer@r`s r<setLevelzHandler.setLevels!'' r;cX|jr|j}nt}||S)z Format the specified record. If a formatter is set, use it. Otherwise, use the default formatter for the module. )r]r4r)rrrs r<rzHandler.formats. > $.CC#Czz&!!!r;c td)z Do whatever it takes to actually log the specified logging record. This version is intended to be implemented by subclasses and so raises a NotImplementedError. z.emit must be implemented by Handler subclasses)NotImplementedErrorr)s r<emitz Handler.emits"#:;; ;r;c||}|rX| |||n#|wxYw|S)a< Conditionally emit the specified logging record. Emission depends on filters which may have been added to the handler. Wrap the actual emission of the record with acquisition/release of the I/O thread lock. Returns whether the filter passed the record for emission. )rCrhrrrj)rrrds r<handlezHandler.handlesg[[    LLNNN  &!!!   s AA-c||_dS)z5 Set the formatter for this handler. N)r]rs r< setFormatterzHandler.setFormattersr;cdS)z Ensure all logging output has been flushed. This version does nothing and is intended to be implemented by subclasses. Nr:rs r<flushz Handler.flushs  r;ct d|_|jr|jtvr t|j=t dS#t wxYw)a% Tidy up any resources used by the handler. This version removes the handler from an internal map of handlers, _handlers, which is used for handler lookup by name. Subclasses should ensure that this gets called from overridden close() methods. TN)rCr^r\rdrDrs r<r"z Handler.closesT  DLz *djI55dj) NNNNNLNNNNs )A Actrtjrtj\}}} tjdt j|||dtjtjd|j}|rytj |j j tdkrA|j}|r8tj |j j tdkA|r!t j|tjn0tjd|jd|jd tjd |jd |jdn9#t($rt*$r"tjd YnwxYwn#t,$rYnwxYw~~~dS#~~~wxYwdSdS) aD Handle errors which occur during an emit() call. This method should be called from handlers when an exception is encountered during an emit() call. If raiseExceptions is false, exceptions get silently ignored. This is what is mostly wanted for a logging system - most users will not care about errors in the logging system, they are more interested in application errors. You could, however, replace this with a custom handler if you wish. The record which was being processed is passed in to this method. z--- Logging error --- Nz Call stack: rfilezLogged from file z, line rz Message: z Arguments: zwUnable to print the message and arguments - possible formatting error. Use the traceback above to help find the error. )r.rIstderrrNwriterr rOrUrVdirnamerXrY__path__rP print_stackr\rrrRecursionErrorrMOSError)rrtvr%r[s r< handleErrorzHandler.handleErrors3 ! sz! |~~HAq"    !:;;;)!QD#*EEE   111 )1I!J!J{"#"#!LE)1I!J!J{"#"#F)%cjAAAAAJ$$$%+___fmmm&EFFF &J$$$:@***:@+++&GHHHH& &&&J$$&R&&&&&&     q"""Aq" C! ! ! ! sND5G$0FG3G G G  GG$ GG$GG$$G)cPt|j}d|jjd|dS)N< ()>)r!r@rrr`s r<rzHandler.__repr__'s-TZ(("n555uuu==r;N)rrrrrrrbrepropertyrr_rurhrjrnrrrrtrvrxr"rrr:r;r<rris,$        8Hh ' 'D,,,$$$      ((( " " ";;;$    $---^>>>>>r;rcLeZdZdZdZd dZdZdZdZdZ e e Z dS) rz A handler class which writes logging records, appropriately formatted, to a stream. Note that this class does not close the stream, as sys.stdout or sys.stderr may be used. rNcdt|| tj}||_dS)zb Initialize the handler. If stream is not specified, sys.stderr is used. N)rrrIr}streamrrs r<rzStreamHandler.__init__4s/  >ZF r;c| |jr.t|jdr|j|dS#|wxYw)z% Flushes the stream. rxN)rhrrrxrjrs r<rxzStreamHandler.flush?sj  { $wt{G<< $ !!### LLNNNNNDLLNNNNs 5A!!A7c ||}|j}|||jz|dS#t $rt $r||YdSwxYw)a Emit a record. If a formatter is specified, it is used to format the record. The record is then written to the stream with a trailing newline. If exception information is present, it is formatted using traceback.print_exception and appended to the stream. If the stream has an 'encoding' attribute, it is used to determine how to do the output to the stream. N)rrr~ terminatorrxrrMr)rrrrs r<rrzStreamHandler.emitJs %++f%%C[F LLt. / / / JJLLLLL     % % %   V $ $ $ $ $ $ %sA A)A>=A>c||jurd}ne|j}| |||_|n#|wxYw|S)z Sets the StreamHandler's stream to the specified value, if it is different. Returns the old stream, if the stream was changed, or None if it wasn't. N)rrhrxrj)rrrAs r< setStreamzStreamHandler.setStream`sk T[ FF[F LLNNN  $    s AA/ct|j}t|jdd}t |}|r|dz }d|jjd|d|dS)Nrr r(r)r!r@getattrrrarr)rr@rs r<rzStreamHandler.__repr__tsaTZ((t{FB//4yy   CKD $ 7 7 7uuuEEr;r7) rrrrrrrxrrrr classmethodr__class_getitem__r:r;r<rr+s J       %%%,(FFF$ L11r;rc2eZdZdZd dZdZdZdZd ZdS) r zO A handler class which writes formatted logging records to disk files. aNFctj|}tj||_||_||_d|vrtj||_||_ ||_ t|_ |r#t|d|_dSt ||dS)zO Open the specified file and use it as the stream for logging. bN)rUfspathrVabspath baseFilenamemodeencodingr text_encodingerrorsdelayopen _builtin_openrrrr_open)rr\rrrrs r<rzFileHandler.__init__s 9X&&GOOH55   d??,X66DM  "  7   T " " "DKKK  " "4 6 6 6 6 6r;c| |jr ||j}d|_t|dr|n8#|j}d|_t|dr|wwxYwt |n#t |wxYw |dS#|wxYw)z$ Closes the stream. Nr")rhrrxrr"rrjrs r<r"zFileHandler.closes   *;++ !%&* "6733+"LLNNN"&&* "6733+"LLNNNN+##D)))) ##D))))) LLNNNNNDLLNNNNs3B9A&3B9&5BB9C/9CC//DcV|j}||j|j|j|jS)zx Open the current base file with the (original) mode and encoding. Return the resulting stream. rr)rrrrr)r open_funcs r<rzFileHandler._opens; & y*DI"&- EEE Er;c|j+|jdks|js||_|jrt||dSdS)a- Emit a record. If the stream was not opened because 'delay' was specified in the constructor, open it before calling the superclass's emit. If stream is not open, current mode is 'w' and `_closed=True`, record will not be emitted (see Issue #42378). Nw)rrr^rrrrr)s r<rrzFileHandler.emits_ ; yCt|"jjll ; -   tV , , , , , - -r;c`t|j}d|jjd|jd|dSNrrrr)r!r@rrrr`s r<rzFileHandler.__repr__s8TZ((!%!8!8!8$:K:K:KUUUSSr;)rNFN) rrrrrr"rrrrr:r;r<r r sv777760EEE--- TTTTTr;r c2eZdZdZefdZedZdS)_StderrHandlerz This class is like a StreamHandler using sys.stderr, but always uses whatever sys.stderr is currently set to rather than the value of sys.stderr at handler construction time. c<t||dS)z) Initialize the handler. N)rrr`s r<rz_StderrHandler.__init__s  u%%%%%r;ctjSr7)rIr}rs r<rz_StderrHandler.streams zr;N)rrrrrrrrr:r;r<rrsR $&&&& Xr;rceZdZdZdZdZdS) PlaceHolderz PlaceHolder instances are used in the Manager logger hierarchy to take the place of nodes for which no loggers have been defined. This class is intended for internal use only and not as part of the public API. c|di|_dS)zY Initialize with the specified logger being a child of this placeholder. N loggerMapraloggers r<rzPlaceHolder.__init__s#T+r;c0||jvr d|j|<dSdS)zJ Add the specified logger as a child of this placeholder. Nrrs r<rIzPlaceHolder.appends+ $. ( (&*DN7 # # # ) (r;N)rrrrrrIr:r;r<rrs< ,,, +++++r;rcx|tkr,t|tstd|jz|adS)z Set the class to be used when instantiating a logger. The class should define __init__() such that only a name argument is required, and the __init__() should call Logger.__init__() (logger not derived from logging.Logger: N)r issubclassrcr _loggerClass)klasss r<r'r'sI  %(( .F#n-.. .LLLr;ctS)zB Return the class to be used when instantiating a logger. )rr:r;r<r#r#s  r;creZdZdZdZedZejdZdZdZ dZ dZ d Z d Z d S) Managerzt There is [under normal circumstances] just one Manager instance, which holds the hierarchy of loggers. cZ||_d|_d|_i|_d|_d|_dS)zT Initialize the manager with the root node of the logger hierarchy. rFN)rootremittedNoHandlerWarning loggerDict loggerClasslogRecordFactory)rrootnodes r<rzManager.__init__s7  ',$ $r;c|jSr7)_disablers r<rzManager.disable's }r;c.t||_dSr7)rerrvalues r<rzManager.disable+s#E** r;c0d}t|tstdt ||jvrx|j|}t|t rU|}|jpt|}||_||j|<| ||| |n=|jpt|}||_||j|<| |tn#twxYw|S)a Get a logger with the specified name (channel name), creating it if it doesn't yet exist. This name is a dot-separated hierarchical name, such as "a", "a.b", "a.b.c" or similar. If a PlaceHolder existed for the specified name [i.e. the logger didn't exist but a child of it did], replace it with the created logger and fix up the parent/child references which pointed to the placeholder to now point to the logger. NzA logger name must be a string) r_rarcrCrrrrmanager_fixupChildren _fixupParentsrD)rrrdphs r<r"zManager.getLogger/s$$$ ><== = t&&_T*b+..+B:$*:lDAAB!%BJ,.DOD)''B///&&r***6d&6,==! (*%""2&&& NNNNLNNNN s B>DDc|tkr,t|tstd|jz||_dS)zY Set the class to be used when instantiating a logger with this Manager. rN)rrrcrr)rrs r<r'zManager.setLoggerClassQsL F??eV,, 2 J"'.!1222 r;c||_dS)zg Set the factory to be used when instantiating a log record with this Manager. N)r)rrs r<r,zManager.setLogRecordFactory[s !(r;c|j}|d}d}|dkr|s|d|}||jvrt||j|<nQ|j|}t |t r|}n,t |tsJ|||dd|dz }|dkr||s|j}||_dS)z Ensure that there are either loggers or placeholders all the way from the specified logger to the root of the logger hierarchy. rBNrrH) rrfindrrr_rrIrparent)rrrirdsubstrobjs r<rzManager._fixupParentsbs | JJsOO 1uubu"1"XFT_,,*5g*>*>''of-c6**(BB%c;77777JJw''' 31q5))A1uubu Br;c|j}t|}|jD]-}|jjd||kr|j|_||_.dS)zk Ensure that children of the placeholder ph are connected to the specified logger. N)rrrrr)rrrrnamelencs r<rzManager._fixupChildrenzsf |d))""$$ # #Ax}XgX&$..!""  # #r;ct|jD]0}t|tr|j1|jjtdS)zj Clear the cache for all loggers in loggerDict Called when level changes are made N) rCrrr_r_cacheclearrrDrloggers r< _clear_cachezManager._clear_cachesu o,,.. & &F&&)) & ##%%%    r;N)rrrrrrrsetterr"r'r,rrrr:r;r<rrs % % %X ^++^+   D!!!(((0 # # #     r;rceZdZdZefdZdZdZdZdZ dZ dZ d d d Z d Z d ZdZddZ d dZ d!dZdZdZdZdZdZdZdZdZdZdZdS)"rar Instances of the Logger class represent a single logging channel. A "logging channel" indicates an area of an application. Exactly how an "area" is defined is up to the application developer. Since an application can have any number of areas, logging channels are identified by a unique string. Application areas can be nested (e.g. an area of "input processing" might include sub-areas "read CSV files", "read XLS files" and "read Gnumeric files"). To cater for this natural nesting, channel names are organized into a namespace hierarchy where levels are separated by periods, much like the Java or Python package namespace. So in the instance given above, channel names might be "input" for the upper level, and "input.csv", "input.xls" and "input.gnu" for the sub-levels. There is no arbitrary limit to the depth of nesting. ct|||_t||_d|_d|_g|_d|_i|_ dS)zJ Initialize the logger with a name and an optional level. NTF) rErrrer@r propagaterTdisabledr)rrr@s r<rzLogger.__init__sU $  ''     r;c`t||_|jdS)zW Set the logging level of this logger. level must be an int or a str. N)rer@rrr`s r<rnzLogger.setLevels-!''  !!#####r;ch|tr|jt||fi|dSdS)z Log 'msg % args' with severity 'DEBUG'. To pass exception information, use the keyword argument exc_info with a true value, e.g. logger.debug("Houston, we have a %s", "thorny problem", exc_info=1) N) isEnabledForr _logrrrrs r<rz Logger.debugH   U # # 2 DIeS$ 1 1& 1 1 1 1 1 2 2r;ch|tr|jt||fi|dSdS)z Log 'msg % args' with severity 'INFO'. To pass exception information, use the keyword argument exc_info with a true value, e.g. logger.info("Houston, we have a %s", "interesting problem", exc_info=1) N)rrrrs r<r$z Logger.infosH   T " " 1 DIdC 0 0 0 0 0 0 0 1 1r;ch|tr|jt||fi|dSdS)z Log 'msg % args' with severity 'WARNING'. To pass exception information, use the keyword argument exc_info with a true value, e.g. logger.warning("Houston, we have a %s", "bit of a problem", exc_info=1) N)rrrrs r<r*zLogger.warningsH   W % % 4 DIgsD 3 3F 3 3 3 3 3 4 4r;c^tjdtd|j|g|Ri|dSNz6The 'warn' method is deprecated, use 'warning' insteadrLwarningsr)DeprecationWarningr*rs r<r)z Logger.warnH $%7 < < < S*4***6*****r;ch|tr|jt||fi|dSdS)z Log 'msg % args' with severity 'ERROR'. To pass exception information, use the keyword argument exc_info with a true value, e.g. logger.error("Houston, we have a %s", "major problem", exc_info=1) N)rr rrs r<rz Logger.errorrr;TrNc,|j|g|Rd|i|dS)zU Convenience method for logging an ERROR with exception information. rNNrrrrNrrs r<rzLogger.exceptions1  3;;;;;F;;;;;r;ch|tr|jt||fi|dSdS)z Log 'msg % args' with severity 'CRITICAL'. To pass exception information, use the keyword argument exc_info with a true value, e.g. logger.critical("Houston, we have a %s", "major disaster", exc_info=1) N)rrrrs r<rzLogger.criticalsH   X & & 5 DIhT 4 4V 4 4 4 4 4 5 5r;c(|j|g|Ri|dS)z@ Don't use this method, use critical() instead. Nrrs r<r z Logger.fatals,  c+D+++F+++++r;ct|tstrtddS||r|j|||fi|dSdS)z Log 'msg % args' with the integer severity 'level'. To pass exception information, use the keyword argument exc_info with a true value, e.g. logger.log(level, "We have a %s", "mysterious problem", exc_info=1) zlevel must be an integerN)r_r`r.rcrrrr@rrrs r<r%z Logger.logsv%%%   :;;;   U # # 2 DIeS$ 1 1& 1 1 1 1 1 2 2r;FrHct}|dS|dkr&|j}|n|}t|s|dz}|dk&|j}d}|rt j5}|dtj||| }|ddkr |dd}dddn #1swxYwY|j |j |j |fS) z Find the stack frame of the caller so that we can note the source file name, line number and function name. N)(unknown file)r(unknown function)NrrHzStack (most recent call last): r{rr) rQrPr]rXrrr~rrr!rYf_linenoco_name)rr stacklevelrPnext_fcorr$s r< findCallerzLogger.findCallers< NN 9BB1nnXF~ A%a(( a 1nnX  ' '# <===%ac2222 9$$!#2#JE  ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ~qz2:u<>E2sC!)4?? Fs '::cp|js,||r||dSdSdS)z Call the handlers for the specified record. This method is used for unpickled records received from a socket, as well as those created locally. Logger-level filtering is applied. N)rrC callHandlersr)s r<rtz Logger.handledsO  &4;;v#6#6 &   f % % % % % & & & &r;ct ||jvr|j|tdS#twxYw)z; Add the specified handler to this logger. N)rCrTrIrDrhdlrs r< addHandlerzLogger.addHandlernsP  DM)) $$T*** NNNNNLNNNN #AAct ||jvr|j|tdS#twxYw)z@ Remove the specified handler from this logger. N)rCrTrMrDrs r< removeHandlerzLogger.removeHandlerysP  t}$$ $$T*** NNNNNLNNNNrcH|}d}|r|jrd}n|jsn |j}||S)a See if this logger has any handlers configured. Loop through all handlers for this logger and its parents in the logger hierarchy. Return True if a handler was found, else False. Stop searching up the hierarchy whenever a logger with the "propagate" attribute set to zero is found - that will be the last logger which is checked for the existence of handlers. FT)rTrr)rrrds r< hasHandlerszLogger.hasHandlerssM   z ; H  r;c|}d}|rG|jD],}|dz}|j|jkr||-|jsd}n|j}|G|dkrt r3|jt jkrt |dSdStrC|jj s9tj d|j zd|j_ dSdSdSdS)a Pass a record to all relevant handlers. Loop through all handlers for this logger and its parents in the logger hierarchy. If no handler was found, output a one-off error message to sys.stderr. Stop searching up the hierarchy whenever a logger with the "propagate" attribute set to zero is found - that will be the last logger whose handlers are called. rrHNz+No handlers could be found for logger "%s" T)rTrr@rtrrr-r.rrrIr}r~r)rrrfoundrs r<rzLogger.callHandlerss!    ( ( >TZ//KK'''; H  QJJ <>Z%555%%f-----65  <)M <   "-/3y"9:::7; 444 J < < < t|d|dS)z= Initialize the logger with the name "root". rN)rrr`s r<rzRootLogger.__init__s  fe,,,,,r;ctdfSr)r"rs r<r2zRootLogger.__reduce__s "}r;N)rrrrrr2r:r;r<r4r4s< --- r;r4ceZdZdZddZdZdZdZdZdZ d Z d d d Z d Z dZ dZdZdZdZddZedZejdZedZdZeeZdS)rzo An adapter for loggers which makes it easier to specify contextual information in logging output. Nc"||_||_dS)ax Initialize the adapter with a logger and a dict-like object which provides contextual information. This constructor signature allows easy stacking of LoggerAdapters, if so desired. You can effectively pass keyword arguments as shown in the following example: adapter = LoggerAdapter(someLogger, dict(p1=v1, p2="v2")) N)rr)rrrs r<rzLoggerAdapter.__init__s  r;c|j|d<||fS)a Process the logging message and keyword arguments passed in to a logging call to insert contextual information. You can either manipulate the message itself, the keyword args or both. Return the message and kwargs modified (or not) to suit your needs. Normally, you'll only need to override this one method in a LoggerAdapter subclass for your specific needs. r)r)rrrs r<rzLoggerAdapter.processs*wF{r;c4|jt|g|Ri|dS)zA Delegate a debug call to the underlying logger. N)r%r rs r<rzLoggerAdapter.debug/. -d---f-----r;c4|jt|g|Ri|dS)zA Delegate an info call to the underlying logger. N)r%rrs r<r$zLoggerAdapter.info5s. s,T,,,V,,,,,r;c4|jt|g|Ri|dS)zC Delegate a warning call to the underlying logger. N)r%rrs r<r*zLoggerAdapter.warning;s. #/////////r;c^tjdtd|j|g|Ri|dSrrrs r<r)zLoggerAdapter.warnArr;c4|jt|g|Ri|dS)zB Delegate an error call to the underlying logger. Nr%r rs r<rzLoggerAdapter.errorFr;r;Trc8|jt|g|Rd|i|dS)zF Delegate an exception call to the underlying logger. rNNr@rs r<rzLoggerAdapter.exceptionLs3 @d@@@X@@@@@@r;c4|jt|g|Ri|dS)zD Delegate a critical call to the underlying logger. N)r%rrs r<rzLoggerAdapter.criticalRs. 3000000000r;c||r2|||\}}|jj||g|Ri|dSdS)z Delegate a log call to the underlying logger, after adding contextual information from this adapter instance. N)rrrr%rs r<r%zLoggerAdapter.logXsg   U # # 9,,sF33KC DKOE3 8 8 8 8 8 8 8 8 8 9 9r;c6|j|S)r))rrr`s r<rzLoggerAdapter.isEnabledForas{''...r;c:|j|dS)zC Set the specified level on the underlying logger. N)rrnr`s r<rnzLoggerAdapter.setLevelgs  U#####r;c4|jS)zD Get the effective level for the underlying logger. )rr'rs r<r'zLoggerAdapter.getEffectiveLevelms{,,...r;c4|jS)z@ See if the underlying logger has any handlers. )rr#rs r<r#zLoggerAdapter.hasHandlersss{&&(((r;FcB|j||||||S)zX Low-level log implementation, proxied to allow nested logger adapters. )rNrr)rr)rr@rrrNrrs r<rzLoggerAdapter._logys5{   !     r;c|jjSr7rrrs r<rzLoggerAdapter.managers {""r;c||j_dSr7rJrs r<rzLoggerAdapter.managers# r;c|jjSr7)rrrs r<rzLoggerAdapter.names {r;c|j}t|}d|jjd|jd|dSr)rr!r'rrr)rrr@s r<rzLoggerAdapter.__repr__sFV557788!%!8!8!8&+++uuuMMr;r7)NNF)rrrrrrrr$r*r)rrrr%rrnr'r#rrrrrrrrrr:r;r<rr s        ... --- 000 +++ ... .2AAAAA 111 999/// $$$ /// )))     ##X# ^$$^$  X NNN $ L11r;rc t |dd}|dd}|dd}|rEtjddD]0}t||1t tjdkr|dd}|d |vrd |vrtd nd |vsd |vrtd ||d d}|d d}|r/d|vrd}ntj |}t||||}n%|d d}t|}|g}|dd} |dd} | tvr*>$&:;;;v%%v)=)=$&JKKK!::j$77zz*c22 .d{{!%#%#3H#=#=#Hd-5fFFFAA$ZZ$77F%f--A3**Y--CJJw,,EG## !;chh!(?1?1"1222HgenQ&788BBU++C # #;&NN3'''""""JJw--E  e$$$ Hyy// !?$!FGGG s KK&&K6c|r%t|tr|tjkrtStj|S)z Return a logger with the specified name, creating it if necessary. If no name is specified, return the root logger. )r_rarrrrr")rs r<r"r"!sD :dC((TTY->-> > # #D ) ))r;cttjdkrttj|g|Ri|dS)z Log a message with severity 'CRITICAL' on the root logger. If the logger has no handlers, call basicConfig() to add a console handler with a pre-defined format. rN)rrrTrrrrrs r<rr+sH  4=Q M#'''''''''r;c&t|g|Ri|dS)z: Don't use this function, use critical() instead. NrrXs r<r r 5s( S"4"""6"""""r;cttjdkrttj|g|Ri|dS)z Log a message with severity 'ERROR' on the root logger. If the logger has no handlers, call basicConfig() to add a console handler with a pre-defined format. rN)rrrTrrrXs r<rr;H  4=Q Js$T$$$V$$$$$r;rc*t|g|Rd|i|dS)z Log a message with severity 'ERROR' on the root logger, with exception information. If the logger has no handlers, basicConfig() is called to add a console handler with a pre-defined format. rNNr)rrNrrs r<rrEs-  #2222x2622222r;cttjdkrttj|g|Ri|dS)z Log a message with severity 'WARNING' on the root logger. If the logger has no handlers, call basicConfig() to add a console handler with a pre-defined format. rN)rrrTrr*rXs r<r*r*MsH  4=Q L&t&&&v&&&&&r;c\tjdtdt|g|Ri|dS)Nz8The 'warn' function is deprecated, use 'warning' insteadrLrrXs r<r)r)WsD M !3Q888 C!$!!!&!!!!!r;cttjdkrttj|g|Ri|dS)z Log a message with severity 'INFO' on the root logger. If the logger has no handlers, call basicConfig() to add a console handler with a pre-defined format. rN)rrrTrr$rXs r<r$r$\sH  4=Q Ic#D###F#####r;cttjdkrttj|g|Ri|dS)z Log a message with severity 'DEBUG' on the root logger. If the logger has no handlers, call basicConfig() to add a console handler with a pre-defined format. rN)rrrTrrrXs r<rrfr[r;cttjdkrttj||g|Ri|dS)z Log 'msg % args' with the integer severity 'level' on the root logger. If the logger has no handlers, call basicConfig() to add a console handler with a pre-defined format. rN)rrrTrr%)r@rrrs r<r%r%psJ  4=Q HUC)$)))&)))))r;cd|tj_tjdS)zB Disable all logging calls of severity 'level' and below. N)rrrr)r@s r<rrzs(!DLLr;cxt|ddD]} |}|r |||n#tt f$rYnwxYw|n#|wxYw#trYxYwdS)z Perform any cleanup actions in the logging system (e.g. flushing buffers). Should be called at application exit. N)reversedrhrxr"rrbrjr.) handlerListrSrSs r<r(r(s{111~&& A   IIKKKGGIIIGGIIII, D IIKKKKAIIKKKK    's@ B+r8r/r!rrrQrVrW__code__rYrZr]rergrgrCrDroWeakSetrrrxrkobjectrrr,r+r&rrrrrr r4rr rEWeakValueDictionaryrdrRrUrYrrr r_defaultLastResortr-rr'r#rrr4rrrrrr"rr rrr*r)r$rr%rr(atexitregisterrrnrrrr:r;r<rs"LKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK,,,,,, D D D6    TY[[            j 7 Y& 7 H          6    73 5++LL555& 7  L1= > >   0  wr%&&6    $37?#4#4    B|'H(46666bbbbbbbbN      MMMMM6MMMB:::::\:::D . . . . ., . . .F4   % 8 9 @ A   mmmmmmmmdIKK$$$$$$$$T#/#/#/#/#/V#/#/#/J.....v...h (G ' ) )  $@>@>@>@>@>h@>@>@>DR2R2R2R2R2GR2R2R2jRTRTRTRTRT-RTRTRTj]"$^G,,  +++++&+++.    {{{{{f{{{B_'_'_'_'_'X_'_'_'D         L2L2L2L2L2FL2L2L2\z' %% yyy@****(((### %%%$(33333'''""" $$$%%%***    &>      '   0()))))r;