{fc%@sdZddlZddlZddlZddlZddlZddlZddlZddlZddddddd d d d d ddddddddddddddddddd d!d"d#d$d%d&d'g%Z yddl Z Wne k re Z nXyddl Z ddlZWne k r:e Z nXd(Zd)Zd*Zd+ZyeeZWnek rzeZnXd,Zeed-rd.ZnejjejjZejZd/Z d/Z!d/Z"d/Z#d0Z$e$Z%d1Z&d2Z'e'Z(d3Z)d4Z*d5Z+i de$6de&6de'6d e)6de*6de+6e$d6e&d6e'd6e'd6e)d 6e*d6e+d6Z,d6Z-d7Z.d8Z/e rej0Z1ne Z1d9Z2d:Z3de4fd;YZ5d<Z6d e4fd=YZ7e7Z8de4fd>YZ9d e4fd?YZ:d@e4fdAYZ;ej<Z=gZ>dBZ?dCZ@d e;fdDYZAdeAfdEYZBd eBfdFYZCdGe4fdHYZDe aEdIZFdJZGdKe4fdLYZHde;fdMYZIdNeIfdOYZJeIaEde4fdPYZKeJe'ZLeLeI_LeHeIjLeI_MdQZNdRZOe dSZPdTZQeQZRdUZSdVZTdWZUeUZVdXZWdYZXdZZYd[ZZe>d\Z[ddl\Z\e\j]e[deAfd]YZ^e a_e e d^Z`d_ZadS(`s Logging package for Python. Based on PEP 282 and comments thereto in comp.lang.python. Copyright (C) 2001-2014 Vinay Sajip. All Rights Reserved. To use, simply 'import logging' and log away! iNt BASIC_FORMATtBufferingFormattertCRITICALtDEBUGtERRORtFATALt FileHandlertFiltert FormattertHandlertINFOt LogRecordtLoggert LoggerAdaptertNOTSETt NullHandlert StreamHandlertWARNtWARNINGt addLevelNamet basicConfigtcaptureWarningstcriticaltdebugtdisableterrort exceptiontfatalt getLevelNamet getLoggertgetLoggerClasstinfotlogt makeLogRecordtsetLoggerClasstwarntwarnings&Vinay Sajip t productions0.5.1.2s07 February 2010cCs)y tWntjdjjSXdS(s5Return the frame object for the caller's stack frame.iN(t Exceptiontsystexc_infottb_frametf_back(((s(/usr/lib64/python2.7/logging/__init__.pyt currentframe?s t _getframecCs tjdS(Ni(R'R,(((s(/usr/lib64/python2.7/logging/__init__.pytFtii2i(iii icCstj|d|S(s Return the textual 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. Otherwise, the string "Level %s" % level is returned. sLevel %s(t _levelNamestget(tlevel((s(/usr/lib64/python2.7/logging/__init__.pyRscCs.tz|t|<|t|(RDRKRLRVRE(Rj((s(/usr/lib64/python2.7/logging/__init__.pyt__str__4scCstst|j}nK|j}t|tscyt|j}Wqctk r_|j}qcXn|jr|||j}n|S(s Return the message for this LogRecord. Return the message for this LogRecord after merging any user-supplied arguments with the message. (t_unicodeR8RER5t basestringt UnicodeErrorRI(RjRE((s(/usr/lib64/python2.7/logging/__init__.pyt getMessage8s   N(t__name__t __module__t__doc__RTRnRoRs(((s(/usr/lib64/python2.7/logging/__init__.pyR s  F c Cs5tdddddddd}|jj||S(s 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. R.iN((R RTt__dict__tupdate(tdictR;((s(/usr/lib64/python2.7/logging/__init__.pyR!Ls!cBsMeZdZejZdddZddZdZ dZ dZ RS(s 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 default value of "%s(message)\n" 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 cCs(|r||_n d|_||_dS(s8 Initialize the formatter with specified format strings. Initialize the formatter either with the specified format string, or a default as described above. Allow for specialized date formatting with the optional datefmt argument (if omitted, you get the ISO8601 format). s %(message)sN(t_fmttdatefmt(RjtfmtR{((s(/usr/lib64/python2.7/logging/__init__.pyRns  cCsV|j|j}|r-tj||}n%tjd|}d||jf}|S(s Return the creation time of the specified LogRecord as formatted text. This method should be called from format() by a formatter which wants to make use of a formatted time. This method can be overridden in formatters to provide for any specific requirement, but the basic behaviour is as follows: if datefmt (a string) is specified, it is used with time.strftime() to format the creation time of the record. Otherwise, the ISO8601 format is used. The resulting string is returned. This function uses a user-configurable function to convert the creation time to a tuple. By default, time.localtime() is used; to change this for a particular formatter instance, set the 'converter' attribute to a function with the same signature as time.localtime() or time.gmtime(). To change it for all formatters, for example if you want all logging times to be shown in GMT, set the 'converter' attribute in the Formatter class. s%Y-%m-%d %H:%M:%Ss%s,%03d(t converterRXRCtstrftimeRY(RjtrecordR{Rltstt((s(/usr/lib64/python2.7/logging/__init__.pyt formatTimes cCshtj}tj|d|d|dd||j}|j|ddkrd|d }n|S(s Format and return the specified exception information as a string. This default implementation just uses traceback.print_exception() iiiis N(t cStringIOtStringIOt tracebacktprint_exceptionRTtgetvaluetclose(RjteitsioR((s(/usr/lib64/python2.7/logging/__init__.pytformatExceptions %   cCs|jjddkS(sK Check if the format uses the creation time of the record. s %(asctime)i(Rztfind(Rj((s(/usr/lib64/python2.7/logging/__init__.pytusesTimescCsA|j|_|jr6|j||j|_ny|j|j}WnVtk r}y)|j j d|_ |j|j}Wqtk r|qXnX|j r|j s|j |j |_ qn|j r=|ddkr|d}ny||j }Wq=tk r9||j j tjd}q=Xn|S(sz 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. sutf-8is treplace(RstmessageRRR{tasctimeRzRwtUnicodeDecodeErrorRDtdecodeR(RURRrR'tgetfilesystemencoding(RjRRte((s(/usr/lib64/python2.7/logging/__init__.pytformats.        N( RtRuRvRCt localtimeR}RTRnRRRR(((s(/usr/lib64/python2.7/logging/__init__.pyR[s(    cBs5eZdZddZdZdZdZRS(sB A formatter suitable for formatting a number of records. cCs|r||_n t|_dS(sm Optionally specify a formatter which will be used to format each individual record. N(tlinefmtt_defaultFormatter(RjR((s(/usr/lib64/python2.7/logging/__init__.pyRns cCsdS(sE Return the header string for the specified records. R.((Rjtrecords((s(/usr/lib64/python2.7/logging/__init__.pyt formatHeaderscCsdS(sE Return the footer string for the specified records. R.((RjR((s(/usr/lib64/python2.7/logging/__init__.pyt formatFooter scCsld}t|dkrh||j|}x$|D]}||jj|}q2W||j|}n|S(sQ Format the specified records and return the result as a string. R.i(RFRRRR(RjRR;R((s(/usr/lib64/python2.7/logging/__init__.pyRs N(RtRuRvRTRnRRR(((s(/usr/lib64/python2.7/logging/__init__.pyRs   cBs#eZdZddZdZRS(s Filter instances are used to perform arbitrary filtering of LogRecords. Loggers and Handlers can optionally use Filter instances to filter records as desired. The base filter class only allows events which are below a certain point in the logger hierarchy. For example, a filter initialized with "A.B" will allow events logged by loggers "A.B", "A.B.C", "A.B.C.D", "A.B.D" etc. but not "A.BB", "B.A.B" etc. If initialized with the empty string, all events are passed. R.cCs||_t||_dS(s Initialize a filter. Initialize with the name of the logger which, together with its children, will have its events allowed through the filter. If no name is specified, allow every event. N(RDRFtnlen(RjRD((s(/usr/lib64/python2.7/logging/__init__.pyRn,s cCse|jdkrdS|j|jkr)dS|jj|jd|jdkrQdS|j|jdkS(s Determine if the specified record is to be logged. Is the specified record to be logged? Returns 0 for no, nonzero for yes. If deemed appropriate, the record may be modified in-place. iit.(RRDR(RjR((s(/usr/lib64/python2.7/logging/__init__.pytfilter7s$(RtRuRvRnR(((s(/usr/lib64/python2.7/logging/__init__.pyR!s  tFilterercBs2eZdZdZdZdZdZRS(s[ A base class for loggers and handlers which allows them to share common code. cCs g|_dS(sE Initialize the list of filters to be an empty list. N(tfilters(Rj((s(/usr/lib64/python2.7/logging/__init__.pyRnKscCs&||jkr"|jj|ndS(s; Add the specified filter to this handler. N(Rtappend(RjR((s(/usr/lib64/python2.7/logging/__init__.pyt addFilterQscCs&||jkr"|jj|ndS(s@ Remove the specified filter from this handler. N(Rtremove(RjR((s(/usr/lib64/python2.7/logging/__init__.pyt removeFilterXscCs7d}x*|jD]}|j|sd}PqqW|S(s 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. ii(RR(RjRR;tf((s(/usr/lib64/python2.7/logging/__init__.pyR_s (RtRuRvRnRRR(((s(/usr/lib64/python2.7/logging/__init__.pyRFs    cCswttt}}}|rs|rs|rsy6|z ||krO|j|nWd|XWqstk roqsXndS(sD Remove a handler reference from the internal cleanup list. N(R2R3t _handlerListRR:(twrR>R?thandlers((s(/usr/lib64/python2.7/logging/__init__.pyt_removeHandlerRefus   cCs3tztjtj|tWdtXdS(sL Add a handler to the internal cleanup list using a weak reference. N(R2RRtweakreftrefRR3(thandler((s(/usr/lib64/python2.7/logging/__init__.pyt_addHandlerRefscBseZdZedZdZdZeeeZdZ dZ dZ dZ dZ d Zd Zd Zd Zd ZdZRS(sq 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. cCsFtj|d|_t||_d|_t||jdS(sz Initializes the instance - basically setting the formatter to None and the filter list to empty. N( RRnRTt_nameR<R1t formatterRt createLock(RjR1((s(/usr/lib64/python2.7/logging/__init__.pyRns     cCs|jS(N(R(Rj((s(/usr/lib64/python2.7/logging/__init__.pytget_namescCsRtz<|jtkr&t|j=n||_|rB|t|(Rj((s(/usr/lib64/python2.7/logging/__init__.pyR>s cCs|jr|jjndS(s. Release the I/O thread lock. N(RR?(Rj((s(/usr/lib64/python2.7/logging/__init__.pyR?s cCst||_dS(s8 Set the logging level of this handler. N(R<R1(RjR1((s(/usr/lib64/python2.7/logging/__init__.pytsetLevelscCs(|jr|j}nt}|j|S(s Format the specified record. If a formatter is set, use it. Otherwise, use the default formatter for the module. (RRR(RjRR|((s(/usr/lib64/python2.7/logging/__init__.pyRs  cCstddS(s 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. s.emit must be implemented by Handler subclassesN(tNotImplementedError(RjR((s(/usr/lib64/python2.7/logging/__init__.pytemitscCsE|j|}|rA|jz|j|Wd|jXn|S(s< 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. N(RR>RR?(RjRR;((s(/usr/lib64/python2.7/logging/__init__.pythandles  cCs ||_dS(s5 Set the formatter for this handler. N(R(RjR|((s(/usr/lib64/python2.7/logging/__init__.pyt setFormatterscCsdS(s Ensure all logging output has been flushed. This version does nothing and is intended to be implemented by subclasses. N((Rj((s(/usr/lib64/python2.7/logging/__init__.pytflush scCs?tz)|jr/|jtkr/t|j=nWdtXdS(s% 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. N(R2RRR3(Rj((s(/usr/lib64/python2.7/logging/__init__.pyRs cCstrtjrtj}zdyLtj|d|d|ddtjtjjd|j|j fWnt k r}nXWd~XndS(sD 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. iiisLogged from file %s, line %s N( traiseExceptionsR'tstderrR(RRRTtwriteRPRVtIOError(RjRR((s(/usr/lib64/python2.7/logging/__init__.pyt handleError#s     (RtRuRvRRnRRtpropertyRDRR>R?RRRRRRRR(((s(/usr/lib64/python2.7/logging/__init__.pyR s         cBs,eZdZddZdZdZRS(s 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. cCs2tj||dkr%tj}n||_dS(sb Initialize the handler. If stream is not specified, sys.stderr is used. N(R RnRTR'Rtstream(RjR((s(/usr/lib64/python2.7/logging/__init__.pyRnBs   cCsK|jz/|jr8t|jdr8|jjnWd|jXdS(s% Flushes the stream. RN(R>RRhRR?(Rj((s(/usr/lib64/python2.7/logging/__init__.pyRMs  cCs-y|j|}|j}d}ts;|j||nyt|trt|ddrd}y|j||Wqtk r|j||j |j qXn|j||Wn+t k r|j||j dnX|j Wn-t tfk rn|j|nXdS(s 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. s%s tencodingu%s sUTF-8N(RRRpRR5tunicodetgetattrRTtUnicodeEncodeErrortencodeRRrRtKeyboardInterruptt SystemExitR(RjRRERtfstufs((s(/usr/lib64/python2.7/logging/__init__.pyRXs,   $ N(RtRuRvRTRnRR(((s(/usr/lib64/python2.7/logging/__init__.pyR;s cBs;eZdZddddZdZdZdZRS(sO A handler class which writes formatted logging records to disk files. taicCs~tdkrd}ntjj||_||_||_||_|rdt j |d|_ nt j ||j dS(sO Open the specified file and use it as the stream for logging. N(tcodecsRTRMRNtabspatht baseFilenametmodeRtdelayR RnRRt_open(RjRPRRR((s(/usr/lib64/python2.7/logging/__init__.pyRns       cCs|jzezP|jr\z|jWd|j}d|_t|drX|jnXnWdtj|XWd|jXdS(s$ Closes the stream. NR(R>RRRTRhRRR?(RjR((s(/usr/lib64/python2.7/logging/__init__.pyRs    cCsI|jdkr't|j|j}ntj|j|j|j}|S(sx Open the current base file with the (original) mode and encoding. Return the resulting stream. N(RRTtopenRRR(RjR((s(/usr/lib64/python2.7/logging/__init__.pyRscCs5|jdkr!|j|_ntj||dS(s Emit a record. If the stream was not opened because 'delay' was specified in the constructor, open it before calling the superclass's emit. N(RRTRRR(RjR((s(/usr/lib64/python2.7/logging/__init__.pyRsN(RtRuRvRTRnRRR(((s(/usr/lib64/python2.7/logging/__init__.pyRs   t PlaceHoldercBs eZdZdZdZRS(s 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. cCsid|6|_dS(sY Initialize with the specified logger being a child of this placeholder. N(RTt loggerMap(Rjtalogger((s(/usr/lib64/python2.7/logging/__init__.pyRnscCs#||jkrd|j||tkr4t|ts4td|jq4n|adS(s 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__() s(logger not derived from logging.Logger: N(R t issubclassR:Rtt _loggerClass(tklass((s(/usr/lib64/python2.7/logging/__init__.pyR"s  cCstS(sB Return the class to be used when instantiating a logger. (R(((s(/usr/lib64/python2.7/logging/__init__.pyRstManagercBs;eZdZdZdZdZdZdZRS(st There is [under normal circumstances] just one Manager instance, which holds the hierarchy of loggers. cCs1||_d|_d|_i|_d|_dS(sT Initialize the manager with the root node of the logger hierarchy. iN(trootRtemittedNoHandlerWarningt loggerDictRTt loggerClass(Rjtrootnode((s(/usr/lib64/python2.7/logging/__init__.pyRns     cCsd}t|ts$tdnt|trE|jd}ntz||jkr|j|}t|tr|}|j pt |}||_ ||j|<|j |||j |qn8|j pt |}||_ ||j|<|j |WdtX|S(s 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. s'A logger name must be string or Unicodesutf-8N(RTR5RqR:RRR2RRRRtmanagert_fixupChildrent _fixupParentsR3(RjRDR;tph((s(/usr/lib64/python2.7/logging/__init__.pyRs,      cCsA|tkr4t|ts4td|jq4n||_dS(sY Set the class to be used when instantiating a logger with this Manager. s(logger not derived from logging.Logger: N(R RR:RtR(RjR((s(/usr/lib64/python2.7/logging/__init__.pyR",s  cCs|j}|jd}d}x|dkr| r|| }||jkrct||j|RRRR9R?R(t handlerListRth((s(/usr/lib64/python2.7/logging/__init__.pytshutdown|s   cBs)eZdZdZdZdZRS(s This handler does nothing. It's intended to be used to avoid the "No handlers could be found for logger XXX" one-off warning. This is important for library code, which may contain code to log events. If a user of the library does not configure logging, the one-off warning might be produced; to avoid this, the library developer simply needs to instantiate a NullHandler and add it to the top-level logger of the library module or package. cCsdS(N((RjR((s(/usr/lib64/python2.7/logging/__init__.pyRscCsdS(N((RjR((s(/usr/lib64/python2.7/logging/__init__.pyRscCs d|_dS(N(RTR(Rj((s(/usr/lib64/python2.7/logging/__init__.pyRs(RtRuRvRRR(((s(/usr/lib64/python2.7/logging/__init__.pyRs   cCs|dk r7tdk rt||||||qnStj|||||}td}|jsz|jtn|jd|dS(s Implementation of showwarnings which redirects to logging, which will first check to see if the file parameter is None. If a file is specified, it will delegate to the original warnings implementation of showwarning. Otherwise, it will call warnings.formatwarning and will log the resulting string to a warnings logger named "py.warnings" with level logging.WARNING. s py.warningss%sN( RTt_warnings_showwarningtwarningst formatwarningRRRRR$(RtcategoryRPRVtfiletlineRR((s(/usr/lib64/python2.7/logging/__init__.pyt _showwarnings    cCsL|r*tdkrHtjatt_qHntdk rHtt_dandS(s If capture is true, redirect all warnings to the logging package. If capture is False, ensure that warnings are not redirected to logging but to their original destinations. N(RRTRt showwarningR(tcapture((s(/usr/lib64/python2.7/logging/__init__.pyRs    (bRvR'RMRCRRRRRGt__all__Rt ImportErrorRTR]R_t __author__t __status__t __version__t__date__RtTrueRpt NameErrortFalseR+RhRNRt__code__RRRZRR\RbRgRRRRRR RRR/RRR<RR=R2R3tobjectR R!RRRRRtWeakValueDictionaryRRRRR RRRRR"RRR R R RRRRRRRRRR$R#RRR RRtatexittregisterRRRR(((s(/usr/lib64/python2.7/logging/__init__.pyts`                k  *%,   GH f `   <