/ lib / logging / __init__.pyc
__init__.pyc
  1  o

  2  ���c=B�@s�dZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z
  3  ddlmZddlm
Zgd�ZddlZdZdZdZd	Ze��Zd
  4  Zd
  5  Zd
  6  Zd
  7  ZdZeZdZd
ZeZdZdZ dZ!edededede de!diZ"eeeeeee e!d�Z#dd�Z$dd�Z%e&ed�r�dd�Z'ndd�Z'ej(�)e%j*j+�Z,d d!�Z-e�.�Z/d"d#�Z0d$d%�Z1e&ed&�s�d'd(�Z2ne�3�Z4d)d(�Z2d*d+�Z5ej6e0e5e1d,�Gd-d.�d.e7�Z8e8a9d/d0�Z:d1d2�Z;d3d4�Z<e�Z=[Gd5d6�d6e7�Z>Gd7d8�d8e>�Z?Gd9d:�d:e>�Z@d;ZAe>eAfe?d<fe@d=fd>�ZBGd?d@�d@e7�Z
e
�ZCGdAdB�dBe7�ZDGdCdD�dDe7�ZEGdEdF�dFe7�ZFe�G�ZHgZIdGdH�ZJdIdJ�ZKGdKdL�dLeF�ZLGdMdN�dNeL�ZMGdOdP�dPeM�ZNGdQdR�dReM�ZOeOe�ZPePZQGdSdT�dTe7�ZRdUdV�ZSdWdX�ZTGdYdZ�dZe7�ZUGd[d\�d\eF�ZVGd]d^�d^eV�ZWeVaXGd_d`�d`e7�ZYeWe�ZZeZeV_ZeUeVjZ�eV_[dadb�Z\d�dcdd�Z]dedf�Z^dgdh�Z_didj�Z`d
  8  dk�dldm�Zadndo�Zbdpdq�Zcdrds�Zddtdu�Zedvdw�Zfefdxdy�ZgeIfdzd{�ZhddliZiei�jeh�Gd|d}�d}eL�Zkdald�d~d�Zmd�d��ZndS)�z�
  9  Logging package for Python. Based on PEP 282 and comments thereto in
 10  comp.lang.python.
 11  
 12  Copyright (C) 2001-2019 Vinay Sajip. All Rights Reserved.
 13  
 14  To use, simply 'import logging' and log away!
 15  �N)�Template)�	Formatter)*�BASIC_FORMAT�BufferingFormatter�CRITICAL�DEBUG�ERROR�FATAL�FileHandler�Filterr�Handler�INFO�	LogRecord�Logger�
LoggerAdapter�NOTSET�NullHandler�
StreamHandler�WARN�WARNING�addLevelName�basicConfig�captureWarnings�critical�debug�disable�error�	exception�fatal�getLevelName�	getLogger�getLoggerClass�info�log�
makeLogRecord�setLoggerClass�shutdown�warn�warning�getLogRecordFactory�setLogRecordFactory�
 16  lastResort�raiseExceptionsz&Vinay Sajip <vinay_sajip@red-dove.com>�
 17  productionz0.5.1.2z07 February 2010T�2�(���
 18  rrrr
rr)rr	rrrr
rrcCs4t�|�}|dur|St�|�}|dur|Sd|S)a�
 19      Return the textual or numeric representation of logging level 'level'.
 20  
 21      If the level is one of the predefined levels (CRITICAL, ERROR, WARNING,
 22      INFO, DEBUG) then you get the corresponding string. If you have
 23      associated levels with names using addLevelName then the name you have
 24      associated with 'level' is returned.
 25  
 26      If a numeric value corresponding to one of the defined levels is passed
 27      in, the corresponding string representation is returned.
 28  
 29      If a string representation of the level is passed in, the corresponding
 30      numeric value is returned.
 31  
 32      If no matching numeric or string value is passed in, the string
 33      'Level %s' % level is returned.
 34      NzLevel %s)�_levelToName�get�_nameToLevel)�level�result�r8�xC:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2800.0_x64__qbz5n2kfra8p0\lib\logging\__init__.pyrws
 35  
 36  rcCs,t�z|t|<|t|<Wt�dSt�w)zy
 37      Associate 'levelName' with 'level'.
 38  
 39      This is used when converting levels to text during message formatting.
 40      N)�_acquireLockr3r5�_releaseLock)r6�	levelNamer8r8r9r�s
 41  
 42  r�	_getframecCs
 43  t�d�S)N�)�sysr=r8r8r8r9�<lambda>�s
 44  r@cCs(zt�tyt��djjYSw)z5Return the frame object for the caller's stack frame.�)�	Exceptionr?�exc_info�tb_frame�f_backr8r8r8r9�currentframe�s
 45  �rFcCsLt|t�r	|}|St|�|kr|tvrtd|��t|}|Std|f��)NzUnknown level: %rz*Level not an integer or a valid string: %r)�
 46  isinstance�int�strr5�
 47  ValueError�	TypeError)r6�rvr8r8r9�_checkLevel�s
 48  ���rMcC�trt��dSdS)z�
 49      Acquire the module-level lock for serializing access to shared data.
 50  
 51      This should be released with _releaseLock().
 52      N)�_lock�acquirer8r8r8r9r:�s�r:cCrN)zK
 53      Release the module-level lock acquired by calling _acquireLock().
 54      N)rO�releaser8r8r8r9r;�s�r;�register_at_forkcC�dS�Nr8��instancer8r8r9�_register_at_fork_reinit_lock��rWcCs&t�zt�|�Wt�dSt�wrT)r:�_at_fork_reinit_lock_weakset�addr;rUr8r8r9rW�scCstD]}|��qt��dSrT)rY�_at_fork_reinitrO��handlerr8r8r9�!_after_at_fork_child_reinit_locks�s
 55  r^)�before�after_in_child�after_in_parentc@s,eZdZdZ	d	dd�Zdd�Zdd�ZdS)
 56  ra
 57      A LogRecord instance represents an event being logged.
 58  
 59      LogRecord instances are created every time something is logged. They
 60      contain all the information pertinent to the event being logged. The
 61      main information passed in is in msg and args, which are combined
 62      using str(msg) % args to create the message field of the record. The
 63      record also includes information such as when the record was created,
 64      the source line where the logging call was made, and any exception
 65      information to be logged.
 66      Nc
 67  

 68  Ks�t��}||_||_|r#t|�dkr#t|dtjj�r#|dr#|d}||_t	|�|_
 69  ||_||_zt
j�|�|_t
j�|j�d|_WntttfyV||_d|_Ynw||_d|_|	|_||_||_||_t|t|�d�d|_|jtd|_t r�t!�"�|_#t!�$�j|_%nd|_#d|_%t&s�d|_'nd|_'t(j)�*d�}|dur�z|�+�j|_'Wn	t,y�Ynwt-r�t.t
d	�r�t
�/�|_0dSd|_0dS)
 70  zK
 71          Initialize a logging record with interesting information.
 72          �rzUnknown moduleNi�g�MainProcess�multiprocessing�getpid)1�time�name�msg�lenrG�collections�abc�Mapping�argsr�	levelname�levelno�pathname�os�path�basename�filename�splitext�modulerKrJ�AttributeErrorrC�exc_text�
 73  stack_info�lineno�funcName�createdrH�msecs�
 74  _startTime�relativeCreated�
 75  logThreads�	threading�	get_ident�thread�current_thread�
 76  threadName�logMultiprocessing�processNamer?�modulesr4�current_processrB�logProcesses�hasattrre�process)
�selfrgr6rprzrhrmrC�func�sinfo�kwargs�ct�mpr8r8r9�__init__sX"�
 77  
 78  �
 79  �
 80  zLogRecord.__init__cCsd|j|j|j|j|jfS)Nz!<LogRecord: %s, %s, %s, %s, "%s">)rgrorprzrh�r�r8r8r9�__repr__cs
 81  �zLogRecord.__repr__cCst|j�}|jr
||j}|S)z�
 82          Return the message for this LogRecord.
 83  
 84          Return the message for this LogRecord after merging any user-supplied
 85          arguments with the message.
 86          )rIrhrm)r�rhr8r8r9�
 87  getMessagegs
 88  
 89  zLogRecord.getMessage�NN)�__name__�
 90  __module__�__qualname__�__doc__r�r�r�r8r8r8r9rs
 91  �HrcCs|adS)z�
 92      Set the factory to be used when instantiating a log record.
 93  
 94      :param factory: A callable which will be called to instantiate
 95      a log record.
 96      N��_logRecordFactory)�factoryr8r8r9r*xsr*cC�tS)zH
 97      Return the factory to be used when instantiating a log record.
 98      r�r8r8r8r9r)�sr)c	Cs&tdddddddd�}|j�|�|S)z�
 99      Make a LogRecord whose attributes are defined by the specified dictionary,
100      This function is useful for converting a logging event received over
101      a socket connection (which is sent as a dictionary) into a LogRecord
102      instance.
103      N�rr8)r��__dict__�update)�dictrLr8r8r9r$�sr$c@sTeZdZdZdZdZe�dej�Z	dd�dd�Z
104  d	d
105  �Zdd�Zd
d�Z
dd�ZdS)�PercentStylez%(message)sz%(asctime)sz
106  %(asctime)z5%\(\w+\)[#0+ -]*(\*|\d+)?(\.(\*|\d+))?[diouxefgcrsa%]N��defaultscCs|p|j|_||_dSrT)�default_format�_fmt�	_defaults)r��fmtr�r8r8r9r��s
107  zPercentStyle.__init__cCs|j�|j�dkS)Nr�r��find�asctime_searchr�r8r8r9�usesTime�szPercentStyle.usesTimecCs*|j�|j�std|j|jdf��dS)z>Validate the input format, ensure it matches the correct stylez"Invalid format '%s' for '%s' stylerN)�validation_pattern�searchr�rJr�r�r8r8r9�validate�s�zPercentStyle.validatecCs&|j}r||jB}n|j}|j|SrT)r�r�r��r��recordr��valuesr8r8r9�_format�s
108  
109  zPercentStyle._formatc
110  Cs2z|�|�WSty}ztd|��d}~ww)Nz(Formatting field not found in record: %s)r��KeyErrorrJ)r�r��er8r8r9�format�s��zPercentStyle.format)r�r�r�r��asctime_formatr��re�compile�Ir�r�r�r�r�r�r8r8r8r9r��sr�c@s@eZdZdZdZdZe�dej�Z	e�d�Z
111  dd�Zdd	�Zd
112  S)�StrFormatStylez	{message}z	{asctime}z{asctimezF^(.?[<>=^])?[+ -]?#?0?(\d+|{\w+})?[,_]?(\.(\d+|{\w+}))?[bcdefgnosx%]?$z^(\d+|\w+)(\.\w+|\[[^]]+\])*$cC�.|j}r||jB}n|j}|jjdi|��S�Nr8)r�r�r�r�r�r8r8r9r���
113  zStrFormatStyle._formatc
114  Cs�t�}z<t�|j�D]3\}}}}|r#|j�|�std|��|�|�|r/|dvr/td|��|r=|j�|�s=td|��q
115  WntyQ}ztd|��d}~ww|sXtd��dS)zKValidate the input format, ensure it is the correct string formatting stylez!invalid field name/expression: %r�rsazinvalid conversion: %rzbad specifier: %rzinvalid format: %sN�invalid format: no fields)	�set�_str_formatter�parser��
116  field_spec�matchrJrZ�fmt_spec)r��fields�_�	fieldname�spec�
117  conversionr�r8r8r9r��s(
118  ��	���zStrFormatStyle.validateN)
r�r�r�r�r�r�r�r�r�r�r�r�r�r8r8r8r9r��s
119  r�cs@eZdZdZdZdZ�fdd�Zdd�Zdd�Zd	d
120  �Z	�Z
121  S)�StringTemplateStylez
122  ${message}z
123  ${asctime}cs"t�j|i|��t|j�|_dSrT)�superr�rr��_tpl)r�rmr���	__class__r8r9r��szStringTemplateStyle.__init__cCs$|j}|�d�dkp|�|j�dkS)Nz$asctimerr��r�r�r8r8r9r��szStringTemplateStyle.usesTimecCs|tj}t�}|�|j�D])}|��}|dr|�|d�q|dr*|�|d�q|�d�dkr5td��q|s<td��dS)N�named�bracedr�$z$invalid format: bare '$' not allowedr�)	r�patternr��finditerr��	groupdictrZ�grouprJ)r�r�r��m�dr8r8r9r��s��zStringTemplateStyle.validatecCr�r�)r�r�r��
124  substituter�r8r8r9r��r�zStringTemplateStyle._format)r�r�r�r�r�r�r�r�r�r��
__classcell__r8r8r�r9r��sr�z"%(levelname)s:%(name)s:%(message)sz{levelname}:{name}:{message}z${levelname}:${name}:${message})�%�{r�c@s`eZdZdZejZddd�dd�ZdZd	Z	dd
125  d�Z
126  dd
�Zdd�Zdd�Z
dd�Zdd�ZdS)ra�
127      Formatter instances are used to convert a LogRecord to text.
128  
129      Formatters need to know how a LogRecord is constructed. They are
130      responsible for converting a LogRecord to (usually) a string which can
131      be interpreted by either a human or an external system. The base Formatter
132      allows a formatting string to be specified. If none is supplied, the
133      style-dependent default value, "%(message)s", "{message}", or
134      "${message}", is used.
135  
136      The Formatter can be initialized with a format string which makes use of
137      knowledge of the LogRecord attributes - e.g. the default value mentioned
138      above makes use of the fact that the user's message and arguments are pre-
139      formatted into a LogRecord's message attribute. Currently, the useful
140      attributes in a LogRecord are described by:
141  
142      %(name)s            Name of the logger (logging channel)
143      %(levelno)s         Numeric logging level for the message (DEBUG, INFO,
144                          WARNING, ERROR, CRITICAL)
145      %(levelname)s       Text logging level for the message ("DEBUG", "INFO",
146                          "WARNING", "ERROR", "CRITICAL")
147      %(pathname)s        Full pathname of the source file where the logging
148                          call was issued (if available)
149      %(filename)s        Filename portion of pathname
150      %(module)s          Module (name portion of filename)
151      %(lineno)d          Source line number where the logging call was issued
152                          (if available)
153      %(funcName)s        Function name
154      %(created)f         Time when the LogRecord was created (time.time()
155                          return value)
156      %(asctime)s         Textual time when the LogRecord was created
157      %(msecs)d           Millisecond portion of the creation time
158      %(relativeCreated)d Time in milliseconds when the LogRecord was created,
159                          relative to the time the logging module was loaded
160                          (typically at application startup time)
161      %(thread)d          Thread ID (if available)
162      %(threadName)s      Thread name (if available)
163      %(process)d         Process ID (if available)
164      %(message)s         The result of record.getMessage(), computed just as
165                          the record is emitted
166      Nr�Tr�cCsV|tvrtdd�t�����t|d||d�|_|r!|j��|jj|_||_dS)a�
167          Initialize the formatter with specified format strings.
168  
169          Initialize the formatter either with the specified format string, or a
170          default as described above. Allow for specialized date formatting with
171          the optional datefmt argument. If datefmt is omitted, you get an
172          ISO8601-like (or RFC 3339-like) format.
173  
174          Use a style parameter of '%', '{' or '$' to specify that you want to
175          use one of %-formatting, :meth:`str.format` (``{}``) formatting or
176          :class:`string.Template` formatting in your format string.
177  
178          .. versionchanged:: 3.2
179             Added the ``style`` parameter.
180          �Style must be one of: %s�,rr�N)�_STYLESrJ�join�keys�_styler�r��datefmt)r�r�r��styler�r�r8r8r9r�7s�
181  
182  
183  zFormatter.__init__z%Y-%m-%d %H:%M:%Sz%s,%03dcCsH|�|j�}|rt�||�}|St�|j|�}|jr"|j||jf}|S)a%
184          Return the creation time of the specified LogRecord as formatted text.
185  
186          This method should be called from format() by a formatter which
187          wants to make use of a formatted time. This method can be overridden
188          in formatters to provide for any specific requirement, but the
189          basic behaviour is as follows: if datefmt (a string) is specified,
190          it is used with time.strftime() to format the creation time of the
191          record. Otherwise, an ISO8601-like (or RFC 3339-like) format is used.
192          The resulting string is returned. This function uses a user-configurable
193          function to convert the creation time to a tuple. By default,
194          time.localtime() is used; to change this for a particular formatter
195          instance, set the 'converter' attribute to a function with the same
196          signature as time.localtime() or time.gmtime(). To change it for all
197          formatters, for example if you want all logging times to be shown in GMT,
198          set the 'converter' attribute in the Formatter class.
199          )�	converterr|rf�strftime�default_time_format�default_msec_formatr})r�r�r�r��sr8r8r9�
200  formatTimeUs�zFormatter.formatTimecCsZt��}|d}t�|d|d|d|�|��}|��|dd�dkr+|dd�}|S)z�
201          Format and return the specified exception information as a string.
202  
203          This default implementation just uses
204          traceback.print_exception()
205          rArrbN������
206  )�io�StringIO�	traceback�print_exception�getvalue�close)r��ei�sio�tbr�r8r8r9�formatExceptionpszFormatter.formatExceptioncC�
207  |j��S)zK
208          Check if the format uses the creation time of the record.
209          )r�r�r�r8r8r9r���
210  zFormatter.usesTimecC�|j�|�SrT)r�r��r�r�r8r8r9�
formatMessage�szFormatter.formatMessagecCs|S)aU
211          This method is provided as an extension point for specialized
212          formatting of stack information.
213  
214          The input data is a string as returned from a call to
215          :func:`traceback.print_stack`, but with the last trailing newline
216          removed.
217  
218          The base implementation just returns the value passed in.
219          r8)r�ryr8r8r9�formatStack�szFormatter.formatStackcCs�|��|_|��r|�||j�|_|�|�}|jr#|js#|�	|j�|_|jr7|dd�dkr2|d}||j}|j
220  rN|dd�dkrF|d}||�|j
221  �}|S)az
222          Format the specified record as text.
223  
224          The record's attribute dictionary is used as the operand to a
225          string formatting operation which yields the returned string.
226          Before formatting the dictionary, a couple of preparatory steps
227          are carried out. The message attribute of the record is computed
228          using LogRecord.getMessage(). If the formatting string uses the
229          time (as determined by a call to usesTime(), formatTime() is
230          called to format the event time. If there is exception information,
231          it is formatted using formatException() and appended to the message.
232          r�Nr�)r��messager�r�r��asctimer�rCrxr�ryr)r�r�r�r8r8r9r��s 
233  

234  
235  zFormatter.format)NNr�TrT)r�r�r�r�rf�	localtimer�r�r�r�r�r�r�r�rr�r8r8r8r9r
236  s*�
237  
rc@s2eZdZdZddd�Zdd�Zdd�Zd	d
238  �ZdS)rzB
239      A formatter suitable for formatting a number of records.
240      NcCs|r||_dSt|_dS)zm
241          Optionally specify a formatter which will be used to format each
242          individual record.
243          N)�linefmt�_defaultFormatter)r�rr8r8r9r��s
244  
245  zBufferingFormatter.__init__cC�dS)zE
246          Return the header string for the specified records.
247          r�r8�r��recordsr8r8r9�formatHeader��zBufferingFormatter.formatHeadercCr)zE
248          Return the footer string for the specified records.
249          r�r8rr8r8r9�formatFooter�r
250  zBufferingFormatter.formatFootercCsJd}t|�dkr#||�|�}|D]
251  }||j�|�}q||�|�}|S)zQ
252          Format the specified records and return the result as a string.
253          r�r)rir	rr�r)r�rrLr�r8r8r9r��szBufferingFormatter.formatrT)r�r�r�r�r�r	rr�r8r8r8r9r�s
254  
255  rc@s"eZdZdZddd�Zdd�ZdS)	ra�
256      Filter instances are used to perform arbitrary filtering of LogRecords.
257  
258      Loggers and Handlers can optionally use Filter instances to filter
259      records as desired. The base filter class only allows events which are
260      below a certain point in the logger hierarchy. For example, a filter
261      initialized with "A.B" will allow events logged by loggers "A.B",
262      "A.B.C", "A.B.C.D", "A.B.D" etc. but not "A.BB", "B.A.B" etc. If
263      initialized with the empty string, all events are passed.
264      r�cCs||_t|�|_dS)z�
265          Initialize a filter.
266  
267          Initialize with the name of the logger which, together with its
268          children, will have its events allowed through the filter. If no
269          name is specified, allow every event.
270          N)rgri�nlen�r�rgr8r8r9r��szFilter.__init__cCsJ|jdkrdS|j|jkrdS|j�|jd|j�dkrdS|j|jdkS)z�
271          Determine if the specified record is to be logged.
272  
273          Returns True if the record should be logged, or False otherwise.
274          If deemed appropriate, the record may be modified in-place.
275          rTF�.)rrgr�r�r8r8r9�filter�s
276  z
Filter.filterN)r�)r�r�r�r�r�rr8r8r8r9r�s
277  
278  rc@�0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
279  S)�Filtererz[
280      A base class for loggers and handlers which allows them to share
281      common code.
282      cCs
283  g|_dS)zE
284          Initialize the list of filters to be an empty list.
285          N)�filtersr�r8r8r9r�r�zFilterer.__init__cCs||jvr
|j�|�dSdS)z;
286          Add the specified filter to this handler.
287          N)r�append�r�rr8r8r9�	addFilter�
288  �zFilterer.addFiltercCs||jvr
|j�|�dSdS)z@
289          Remove the specified filter from this handler.
290          N)r�removerr8r8r9�removeFilterrzFilterer.removeFiltercCs@d}|jD]}t|d�r|�|�}n||�}|sd}|Sq|S)ah
291          Determine if a record is loggable by consulting all the filters.
292  
293          The default is to allow the record to be logged; any filter can veto
294          this and the record is then dropped. Returns a zero value if a record
295          is to be dropped, else non-zero.
296  
297          .. versionchanged:: 3.2
298  
299             Allow filters to be just callables.
300          TrF)rr�r)r�r�rL�fr7r8r8r9r&s
301  
302  �zFilterer.filterN)r�r�r�r�r�rrrr8r8r8r9r
srcCsbttt}}}|r+|r-|r/|�z||vr!|�|�W|�dSW|�dS|�wdSdSdS)zD
303      Remove a handler reference from the internal cleanup list.
304      N)r:r;�_handlerListr)�wrrPrQ�handlersr8r8r9�_removeHandlerRefDs
305  ��rcCs.t�zt�t�|t��Wt�dSt�w)zL
306      Add a handler to the internal cleanup list using a weak reference.
307      N)r:rr�weakref�refrr;r\r8r8r9�_addHandlerRefUsr c@s�eZdZdZefdd�Zdd�Zdd�Zeee�Z	dd	�Z
308  d
309  d�Zdd
�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"S)#raq
310      Handler instances dispatch logging events to specific destinations.
311  
312      The base handler class. Acts as a placeholder which defines the Handler
313      interface. Handlers can optionally use Formatter instances to format
314      records as desired. By default, no formatter is specified; in this case,
315      the 'raw' message as determined by record.message is logged.
316      cCs:t�|�d|_t|�|_d|_d|_t|�|��dS)zz
317          Initializes the instance - basically setting the formatter to None
318          and the filter list to empty.
319          NF)	rr��_namerMr6�	formatter�_closedr �
320  createLock�r�r6r8r8r9r�hs
321  
322  zHandler.__init__cC�|jSrT)r!r�r8r8r9�get_namevszHandler.get_namecCsLt�z|jtvr
t|j=||_|r|t|<Wt�dSWt�dSt�wrT)r:r!�	_handlersr;r
r8r8r9�set_nameys
323  
324  
325  �zHandler.set_namecCst��|_t|�dS)zU
326          Acquire a thread lock for serializing access to the underlying I/O.
327          N)r��RLock�lockrWr�r8r8r9r$�s
328  zHandler.createLockcCs|j��dSrT)r+r[r�r8r8r9r[�szHandler._at_fork_reinitcC�|jr
329  |j��dSdS)z.
330          Acquire the I/O thread lock.
331          N)r+rPr�r8r8r9rP���zHandler.acquirecCr,)z.
332          Release the I/O thread lock.
333          N)r+rQr�r8r8r9rQ�r-zHandler.releasecCst|�|_dS)zX
334          Set the logging level of this handler.  level must be an int or a str.
335          N)rMr6r%r8r8r9�setLevel��zHandler.setLevelcCs|jr|j}nt}|�|�S)z�
336          Format the specified record.
337  
338          If a formatter is set, use it. Otherwise, use the default formatter
339          for the module.
340          )r"rr�)r�r�r�r8r8r9r��s
341  zHandler.formatcCstd��)z�
342          Do whatever it takes to actually log the specified logging record.
343  
344          This version is intended to be implemented by subclasses and so
345          raises a NotImplementedError.
346          z.emit must be implemented by Handler subclasses)�NotImplementedErrorr�r8r8r9�emit�szHandler.emitcCs>|�|�}|r|��z|�|�W|��|S|��w|S)a<
347          Conditionally emit the specified logging record.
348  
349          Emission depends on filters which may have been added to the handler.
350          Wrap the actual emission of the record with acquisition/release of
351          the I/O thread lock. Returns whether the filter passed the record for
352          emission.
353          )rrPr1rQ)r�r�rLr8r8r9�handle�s
354  	
355  �zHandler.handlecC�
356  ||_dS)z5
357          Set the formatter for this handler.
358          N)r"r�r8r8r9�setFormatter�r�zHandler.setFormattercCr)z�
359          Ensure all logging output has been flushed.
360  
361          This version does nothing and is intended to be implemented by
362          subclasses.
363          Nr8r�r8r8r9�flush�sz
Handler.flushcCsRt�z!d|_|jr|jtvrt|j=Wt�dSWt�dSWt�dSt�w)a%
364          Tidy up any resources used by the handler.
365  
366          This version removes the handler from an internal map of handlers,
367          _handlers, which is used for handler lookup by name. Subclasses
368          should ensure that this gets called from overridden close()
369          methods.
370          TN)r:r#r!r(r;r�r8r8r9r��s
371  
372  
373  �
374  �z
Handler.closecCsBtr�tjr�t��\}}}z�zvtj�d�t�|||dtj�tj�d�|j}|rFtj	�
375  |jj�t
dkrF|j}|rFtj	�
376  |jj�t
dks5|rQtj|tjd�ntj�d|j|jf�ztj�d|j|jf�Wntys�ty�tj�d�YnwWn	ty�YnwW~~~dSW~~~dS~~~wdSdS)	aD
377          Handle errors which occur during an emit() call.
378  
379          This method should be called from handlers when an exception is
380          encountered during an emit() call. If raiseExceptions is false,
381          exceptions get silently ignored. This is what is mostly wanted
382          for a logging system - most users will not care about errors in
383          the logging system, they are more interested in application errors.
384          You could, however, replace this with a custom handler if you wish.
385          The record which was being processed is passed in to this method.
386          z--- Logging error ---
387  NzCall stack:
388  r��filezLogged from file %s, line %s
389  zMessage: %r
390  Arguments: %s
391  zwUnable to print the message and arguments - possible formatting error.
392  Use the traceback above to help find the error.
393  )r,r?�stderrrC�writer�r�rDrqrr�dirname�f_code�co_filename�__path__rE�print_stackrtrzrhrm�RecursionErrorrB�OSError)r�r��t�vr��framer8r8r9�handleError�sN
394  �����
395  �����
396  ��zHandler.handleErrorcCst|j�}d|jj|fS)Nz	<%s (%s)>)rr6r�r�r%r8r8r9r�s
397  zHandler.__repr__N)r�r�r�r�rr�r'r)�propertyrgr$r[rPrQr.r�r1r2r4r5r�rDr�r8r8r8r9r_s&
398  

399  	/rc@s>eZdZdZdZddd�Zdd�Zdd	�Zd
400  d�Zdd
�Z	dS)rz�
401      A handler class which writes logging records, appropriately formatted,
402      to a stream. Note that this class does not close the stream, as
403      sys.stdout or sys.stderr may be used.
404      r�NcCs"t�|�|durtj}||_dS)zb
405          Initialize the handler.
406  
407          If stream is not specified, sys.stderr is used.
408          N)rr�r?r8�stream�r�rFr8r8r9r�*s
409  
410  zStreamHandler.__init__cCsZ|��z#|jrt|jd�r!|j��W|��dSW|��dSW|��dS|��w)z%
411          Flushes the stream.
412          r5N)rPrFr�r5rQr�r8r8r9r55s��zStreamHandler.flushcCs\z|�|�}|j}|�||j�|��WdSty�ty-|�|�YdSw)a�
413          Emit a record.
414  
415          If a formatter is specified, it is used to format the record.
416          The record is then written to the stream with a trailing newline.  If
417          exception information is present, it is formatted using
418          traceback.print_exception and appended to the stream.  If the stream
419          has an 'encoding' attribute, it is used to determine how to do the
420          output to the stream.
421          N)r�rFr9�
422  terminatorr5r?rBrD)r�r�rhrFr8r8r9r1@s
423  �zStreamHandler.emitcCsH||jur	d}|S|j}|��z|��||_W|��|S|��w)z�
424          Sets the StreamHandler's stream to the specified value,
425          if it is different.
426  
427          Returns the old stream, if the stream was changed, or None
428          if it wasn't.
429          N)rFrPr5rQ)r�rFr7r8r8r9�	setStreamVs
430  	�
431  �zStreamHandler.setStreamcCs>t|j�}t|jdd�}t|�}|r|d7}d|jj||fS)Nrgr�� z<%s %s(%s)>)rr6�getattrrFrIr�r�)r�r6rgr8r8r9r�js
432  zStreamHandler.__repr__rT)
433  r�r�r�r�rHr�r5r1rIr�r8r8r8r9r!s
434  rc@s:eZdZdZddd�Zdd�Zd	d
435  �Zdd�Zd
d�ZdS)r
436  zO
437      A handler class which writes formatted logging records to disk files.
438      �aNFcCsvt�|�}tj�|�|_||_||_d|vrt�|�|_||_	||_
439  t|_|r1t
�|�d|_dSt�||���dS)zO
440          Open the specified file and use it as the stream for logging.
441          �bN)rq�fspathrr�abspath�baseFilename�mode�encodingr��
text_encoding�errors�delay�open�
_builtin_openrr�rFr�_open)r�rtrQrRrUrTr8r8r9r�xs
442  
443  
444  zFileHandler.__init__c	Cs�|��z?z1|jr0z|��W|j}d|_t|d�r|��n|j}d|_t|d�r/|��wwWt�|�nt�|�wW|��dS|��w)z$
445          Closes the stream.
446          Nr�)rPrFr5r�r�rrQrGr8r8r9r��s&
447  
448  ��
449  
450  ��zFileHandler.closecCs|j}||j|j|j|jd�S)zx
451          Open the current base file with the (original) mode and encoding.
452          Return the resulting stream.
453          �rRrT)rWrPrQrRrT)r��	open_funcr8r8r9rX�s
454  �zFileHandler._opencCs>|jdur|jdks
|js|��|_|jrt�||�dSdS)a-
455          Emit a record.
456  
457          If the stream was not opened because 'delay' was specified in the
458          constructor, open it before calling the superclass's emit.
459  
460          If stream is not open, current mode is 'w' and `_closed=True`, record
461          will not be emitted (see Issue #42378).
462          N�w)rFrQr#rXrr1r�r8r8r9r1�s
463  
464  
465  �zFileHandler.emitcCst|j�}d|jj|j|fS�Nz<%s %s (%s)>)rr6r�r�rPr%r8r8r9r��s
466  zFileHandler.__repr__)rLNFN)	r�r�r�r�r�r�rXr1r�r8r8r8r9r
467  ts
468  	r
469  c@s(eZdZdZefdd�Zedd��ZdS)�_StderrHandlerz�
470      This class is like a StreamHandler using sys.stderr, but always uses
471      whatever sys.stderr is currently set to rather than the value of
472      sys.stderr at handler construction time.
473      cCst�||�dS)z)
474          Initialize the handler.
475          N)rr�r%r8r8r9r���z_StderrHandler.__init__cCstjSrT)r?r8r�r8r8r9rF��z_StderrHandler.streamN)r�r�r�r�rr�rErFr8r8r8r9r]�s
476  r]c@� eZdZdZdd�Zdd�ZdS)�PlaceHolderz�
477      PlaceHolder instances are used in the Manager logger hierarchy to take
478      the place of nodes for which no loggers have been defined. This class is
479      intended for internal use only and not as part of the public API.
480      cCs|di|_dS)zY
481          Initialize with the specified logger being a child of this placeholder.
482          N��	loggerMap�r��aloggerr8r8r9r��r/zPlaceHolder.__init__cCs||jvrd|j|<dSdS)zJ
483          Add the specified logger as a child of this placeholder.
484          Nrbrdr8r8r9r�s
485  �zPlaceHolder.appendN)r�r�r�r�r�rr8r8r8r9ra��racCs(|tkrt|t�std|j��|adS)z�
486      Set the class to be used when instantiating a logger. The class should
487      define __init__() such that only a name argument is required, and the
488      __init__() should call Logger.__init__()
489      �(logger not derived from logging.Logger: N)r�
490  issubclassrKr��_loggerClass)�klassr8r8r9r%�s
491  �r%cCr�)zB
492      Return the class to be used when instantiating a logger.
493      )rir8r8r8r9r!r
494  r!c@sbeZdZdZdd�Zedd��Zejdd��Zdd�Zd	d
495  �Z	dd�Z
496  d
d�Zdd�Zdd�Z
dS)�Managerzt
497      There is [under normal circumstances] just one Manager instance, which
498      holds the hierarchy of loggers.
499      cCs(||_d|_d|_i|_d|_d|_dS)zT
500          Initialize the manager with the root node of the logger hierarchy.
501          rFN)�rootr�emittedNoHandlerWarning�
502  loggerDict�loggerClass�logRecordFactory)r��rootnoder8r8r9r�s
503  zManager.__init__cCr&rT)�_disabler�r8r8r9rr_zManager.disablecCst|�|_dSrT)rMrr�r��valuer8r8r9rscCs�d}t|t�std��t�zL||jvr;|j|}t|t�r:|}|jp$t|�}||_||j|<|�	||�|�
504  |�n|jp?t|�}||_||j|<|�
505  |�Wt�|SWt�|St�w)a�
506          Get a logger with the specified name (channel name), creating it
507          if it doesn't yet exist. This name is a dot-separated hierarchical
508          name, such as "a", "a.b", "a.b.c" or similar.
509  
510          If a PlaceHolder existed for the specified name [i.e. the logger
511          didn't exist but a child of it did], replace it with the created
512          logger and fix up the parent/child references which pointed to the
513          placeholder to now point to the logger.
514          NzA logger name must be a string)rGrIrKr:rnrarori�manager�_fixupChildren�
_fixupParentsr;)r�rgrL�phr8r8r9r #s2
515  
516  
517  
518  
519  
520  �
521  ���zManager.getLoggercCs*|tkrt|t�std|j��||_dS)zY
522          Set the class to be used when instantiating a logger with this Manager.
523          rgN)rrhrKr�ro)r�rjr8r8r9r%Es
524  �
525  zManager.setLoggerClasscCr3)zg
526          Set the factory to be used when instantiating a log record with this
527          Manager.
528          N)rp)r�r�r8r8r9r*Os
529  zManager.setLogRecordFactorycCs�|j}|�d�}d}|dkrK|sK|d|�}||jvr#t|�|j|<n|j|}t|t�r0|}nt|t�s7J�|�|�|�dd|d�}|dkrK|r|sP|j}||_dS)z�
530          Ensure that there are either loggers or placeholders all the way
531          from the specified logger to the root of the logger hierarchy.
532          rNrrb)	rg�rfindrnrarGrrrl�parent)r�rerg�irL�substr�objr8r8r9rwVs"
533  
534  
535  
536  
537  �
538  zManager._fixupParentscCsD|j}t|�}|j��D]}|jjd|�|kr|j|_||_qdS)zk
539          Ensure that children of the placeholder ph are connected to the
540          specified logger.
541          N)rgrircr�rz)r�rxrerg�namelen�cr8r8r9rvns��zManager._fixupChildrencCs@t�|j��D]}t|t�r|j��q|jj��t�dS)zj
542          Clear the cache for all loggers in loggerDict
543          Called when level changes are made
544          N)	r:rnr�rGr�_cache�clearrlr;�r��loggerr8r8r9�_clear_cache{s
545  
546  �
547  zManager._clear_cacheN)r�r�r�r�r�rEr�setterr r%r*rwrvr�r8r8r8r9rks
548  
549  "
550  
rkc@s�eZdZdZefdd�Zdd�Zdd�Zdd	�Zd
551  d�Z	dd
�Z
552  dd�Zdd�dd�Zdd�Z
dd�Zdd�Zd7dd�Z	d8dd �Z		d9d!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�ZdS):rar
553      Instances of the Logger class represent a single logging channel. A
554      "logging channel" indicates an area of an application. Exactly how an
555      "area" is defined is up to the application developer. Since an
556      application can have any number of areas, logging channels are identified
557      by a unique string. Application areas can be nested (e.g. an area
558      of "input processing" might include sub-areas "read CSV files", "read
559      XLS files" and "read Gnumeric files"). To cater for this natural nesting,
560      channel names are organized into a namespace hierarchy where levels are
561      separated by periods, much like the Java or Python package namespace. So
562      in the instance given above, channel names might be "input" for the upper
563      level, and "input.csv", "input.xls" and "input.gnu" for the sub-levels.
564      There is no arbitrary limit to the depth of nesting.
565      cCs<t�|�||_t|�|_d|_d|_g|_d|_i|_	dS)zJ
566          Initialize the logger with a name and an optional level.
567          NTF)
568  rr�rgrMr6rz�	propagater�disabledr�)r�rgr6r8r8r9r��s
569  
570  
571  zLogger.__init__cCst|�|_|j��dS)zW
572          Set the logging level of this logger.  level must be an int or a str.
573          N)rMr6rur�r%r8r8r9r.�s
574  zLogger.setLevelcO�(|�t�r|jt||fi|��dSdS)z�
575          Log 'msg % args' with severity 'DEBUG'.
576  
577          To pass exception information, use the keyword argument exc_info with
578          a true value, e.g.
579  
580          logger.debug("Houston, we have a %s", "thorny problem", exc_info=1)
581          N)�isEnabledForr�_log�r�rhrmr�r8r8r9r��
582  	�zLogger.debugcOr�)z�
583          Log 'msg % args' with severity 'INFO'.
584  
585          To pass exception information, use the keyword argument exc_info with
586          a true value, e.g.
587  
588          logger.info("Houston, we have a %s", "interesting problem", exc_info=1)
589          N)r�r
r�r�r8r8r9r"�r�zLogger.infocOr�)z�
590          Log 'msg % args' with severity 'WARNING'.
591  
592          To pass exception information, use the keyword argument exc_info with
593          a true value, e.g.
594  
595          logger.warning("Houston, we have a %s", "bit of a problem", exc_info=1)
596          N)r�rr�r�r8r8r9r(�r�zLogger.warningcO�*t�dtd�|j|g|�Ri|��dS�Nz6The 'warn' method is deprecated, use 'warning' insteadrA��warningsr'�DeprecationWarningr(r�r8r8r9r'���zLogger.warncOr�)z�
597          Log 'msg % args' with severity 'ERROR'.
598  
599          To pass exception information, use the keyword argument exc_info with
600          a true value, e.g.
601  
602          logger.error("Houston, we have a %s", "major problem", exc_info=1)
603          N)r�rr�r�r8r8r9r�r�zLogger.errorT�rCcOs |j|g|�Rd|i|��dS)zU
604          Convenience method for logging an ERROR with exception information.
605          rCN�r�r�rhrCrmr�r8r8r9r�s zLogger.exceptioncOr�)z�
606          Log 'msg % args' with severity 'CRITICAL'.
607  
608          To pass exception information, use the keyword argument exc_info with
609          a true value, e.g.
610  
611          logger.critical("Houston, we have a %s", "major disaster", exc_info=1)
612          N)r�rr�r�r8r8r9r�r�zLogger.criticalcOs|j|g|�Ri|��dS)z@
613          Don't use this method, use critical() instead.
614          N�rr�r8r8r9r�szLogger.fatalcOsBt|t�s
trtd��dS|�|�r|j|||fi|��dSdS)z�
615          Log 'msg % args' with the integer severity 'level'.
616  
617          To pass exception information, use the keyword argument exc_info with
618          a true value, e.g.
619  
620          logger.log(level, "We have a %s", "mysterious problem", exc_info=1)
621          zlevel must be an integerN)rGrHr,rKr�r��r�r6rhrmr�r8r8r9r#�s
622  	
623  �z
624  Logger.logFrbc
625  Cs�t�}|dur
626  |j}|}|r|dkr|j}|d8}|r|dks|s#|}d}t|d�rp|j}tj�|j�}|tkr<|j}q%d}|rdt	�
627  �}	|	�d�tj
||	d�|	��}|ddkr`|dd�}|	��|j|j|j|f}	|S|S)	z�
628          Find the stack frame of the caller so that we can note the source
629          file name, line number and function name.
630          Nrb)�(unknown file)r�(unknown function)Nr;zStack (most recent call last):
631  r6r�r�)rFrEr�r;rqrr�normcaser<�_srcfiler�r�r9r�r>r�r��f_lineno�co_name)
632  r�ry�
633  stacklevelr�orig_frL�cortr�r�r8r8r9�
634  findCaller
s:�
635  
636  zLogger.findCallerNc

637  CsZt|||||||||
638  �	}|	dur+|	D]}|dvs||jvr#td|��|	||j|<q|S)zr
639          A factory method which can be overridden in subclasses to create
640          specialized LogRecords.
641          N)rrz$Attempt to overwrite %r in LogRecord)r�r�r�)
r�rgr6�fn�lnorhrmrCr��extrar�rL�keyr8r8r9�
642  makeRecord1s�zLogger.makeRecordc
Cs�d}trz|�||�\}	}
643  }}Wntyd\}	}
644  }Ynwd\}	}
645  }|r=t|t�r4t|�||jf}n	t|t�s=t�	�}|�
646  |j||	|
647  ||||||�
648  }|�|�dS)z�
649          Low-level logging routine which creates a LogRecord and then calls
650          all the handlers of this logger to handle the record.
651          N)r�rr�)
r�r�rJrG�
BaseException�type�
__traceback__�tupler?rCr�rgr2)
r�r6rhrmrCr�ryr�r�r�r�r�r�r8r8r9r�@s"�
652  
653  
654  �zLogger._logcCs&|js|�|�r|�|�dSdSdS)z�
655          Call the handlers for the specified record.
656  
657          This method is used for unpickled records received from a socket, as
658          well as those created locally. Logger-level filtering is applied.
659          N)r�r�callHandlersr�r8r8r9r2Zs�z
Logger.handlecCs>t�z||jvr|j�|�Wt�dSWt�dSt�w)z;
660          Add the specified handler to this logger.
661          N)r:rrr;�r��hdlrr8r8r9�
662  addHandlerd�
663  
664  �zLogger.addHandlercCs>t�z||jvr|j�|�Wt�dSWt�dSt�w)z@
665          Remove the specified handler from this logger.
666          N)r:rrr;r�r8r8r9�
removeHandleror�zLogger.removeHandlercCs6|}d}|r|jrd}	|S|js	|S|j}|s|S)a�
667          See if this logger has any handlers configured.
668  
669          Loop through all handlers for this logger and its parents in the
670          logger hierarchy. Return True if a handler was found, else False.
671          Stop searching up the hierarchy whenever a logger with the "propagate"
672          attribute set to zero is found - that will be the last logger which
673          is checked for the existence of handlers.
674          FT)rr�rz)r�rrLr8r8r9�hasHandlerszs
675  ���zLogger.hasHandlerscCs�|}d}|r&|jD]}|d}|j|jkr|�|�q	|js!d}n|j}|s|dkrPtr;|jtjkr9t�|�dSdStrR|jj	sTt
676  j�d|j
�d|j_	dSdSdSdS)a�
677          Pass a record to all relevant handlers.
678  
679          Loop through all handlers for this logger and its parents in the
680          logger hierarchy. If no handler was found, output a one-off error
681          message to sys.stderr. Stop searching up the hierarchy whenever a
682          logger with the "propagate" attribute set to zero is found - that
683          will be the last logger whose handlers are called.
684          rrbNz+No handlers could be found for logger "%s"
685  T)rror6r2r�rzr+r,rurmr?r8r9rg)r�r�r�foundr�r8r8r9r��s0
686  
687  
688  ��	���zLogger.callHandlerscCs"|}|r|jr
689  |jS|j}|stS)z�
690          Get the effective level for this logger.
691  
692          Loop through this logger and its parents in the logger hierarchy,
693          looking for a non-zero logging level. Return the first one found.
694          )r6rzrr�r8r8r9�getEffectiveLevel�s�zLogger.getEffectiveLevelc
695  Cs�|jrdSz|j|WStyCt�z)|jj|kr$d}|j|<n||��k}|j|<Wt�|YSWt�|YSt�ww)�;
696          Is this logger enabled for level 'level'?
697          F)r�r�r�r:rurr�r;)r�r6�
698  is_enabledr8r8r9r��s$
699  ����zLogger.isEnabledForcCs&|j|ur
d�|j|f�}|j�|�S)ab
700          Get a logger which is a descendant to this one.
701  
702          This is a convenience method, such that
703  
704          logging.getLogger('abc').getChild('def.ghi')
705  
706          is the same as
707  
708          logging.getLogger('abc.def.ghi')
709  
710          It's useful, for example, when the parent logger is named using
711          __name__ rather than a literal string.
712          r)rlr�rgrur )r��suffixr8r8r9�getChild�s
713  zLogger.getChildcCs t|���}d|jj|j|fSr\)rr�r�r�rgr%r8r8r9r��szLogger.__repr__cCs,t|j�|urddl}|�d��t|jffS)Nrzlogger cannot be pickled)r rg�pickle�
PicklingError)r�r�r8r8r9�
714  __reduce__�s
715  zLogger.__reduce__)Frb)NNN)NNFrb)r�r�r�r�rr�r.rr"r(r'rrrrr#r�r�r�r2r�r�r�r�r�r�r�r�r�r8r8r8r9r�s:

716  %
717  �
718  �
719  rc@r`)�
720  RootLoggerz�
721      A root logger is not that different to any other logger, except that
722      it must have a logging level and there is only one instance of it in
723      the hierarchy.
724      cCst�|d|�dS)z=
725          Initialize the logger with the name "root".
726          rlN)rr�r%r8r8r9r��szRootLogger.__init__cCstdfSr�)r r�r8r8r9r��szRootLogger.__reduce__N)r�r�r�r�r�r�r8r8r8r9r��rfr�c@s�eZdZdZd+dd�Zdd�Zdd�Zd	d
727  �Zdd�Zd
d�Z	dd�Z
728  dd�dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd �Zd,d"d#�Zed$d%��Zejd&d%��Zed'd(��Zd)d*�ZdS)-rzo
729      An adapter for loggers which makes it easier to specify contextual
730      information in logging output.
731      NcCs||_||_dS)ax
732          Initialize the adapter with a logger and a dict-like object which
733          provides contextual information. This constructor signature allows
734          easy stacking of LoggerAdapters, if so desired.
735  
736          You can effectively pass keyword arguments as shown in the
737          following example:
738  
739          adapter = LoggerAdapter(someLogger, dict(p1=v1, p2="v2"))
740          N)r�r�)r�r�r�r8r8r9r�	s
741  zLoggerAdapter.__init__cCs|j|d<||fS)a�
742          Process the logging message and keyword arguments passed in to
743          a logging call to insert contextual information. You can either
744          manipulate the message itself, the keyword args or both. Return
745          the message and kwargs modified (or not) to suit your needs.
746  
747          Normally, you'll only need to override this one method in a
748          LoggerAdapter subclass for your specific needs.
749          r�)r�)r�rhr�r8r8r9r�s
750  
751  zLoggerAdapter.processcO�|jt|g|�Ri|��dS)zA
752          Delegate a debug call to the underlying logger.
753          N)r#rr�r8r8r9r'�zLoggerAdapter.debugcOr�)zA
754          Delegate an info call to the underlying logger.
755          N)r#r
r�r8r8r9r"-r�zLoggerAdapter.infocOr�)zC
756          Delegate a warning call to the underlying logger.
757          N)r#rr�r8r8r9r(3r�zLoggerAdapter.warningcOr�r�r�r�r8r8r9r'9r�zLoggerAdapter.warncOr�)zB
758          Delegate an error call to the underlying logger.
759          N�r#rr�r8r8r9r>r�zLoggerAdapter.errorTr�cOs"|jt|g|�Rd|i|��dS)zF
760          Delegate an exception call to the underlying logger.
761          rCNr�r�r8r8r9rDs"zLoggerAdapter.exceptioncOr�)zD
762          Delegate a critical call to the underlying logger.
763          N)r#rr�r8r8r9rJr�zLoggerAdapter.criticalcOs>|�|�r|�||�\}}|jj||g|�Ri|��dSdS)z�
764          Delegate a log call to the underlying logger, after adding
765          contextual information from this adapter instance.
766          N)r�r�r�r#r�r8r8r9r#Ps
767   �zLoggerAdapter.logcCr�)r�)r�r�r%r8r8r9r�YszLoggerAdapter.isEnabledForcCs|j�|�dS)zC
768          Set the specified level on the underlying logger.
769          N)r�r.r%r8r8r9r._r^zLoggerAdapter.setLevelcCr�)zD
770          Get the effective level for the underlying logger.
771          )r�r�r�r8r8r9r�er�zLoggerAdapter.getEffectiveLevelcCr�)z@
772          See if the underlying logger has any handlers.
773          )r�r�r�r8r8r9r�kr�zLoggerAdapter.hasHandlersFcCs|jj||||||d�S)zX
774          Low-level log implementation, proxied to allow nested logger adapters.
775          )rCr�ry)r�r�)r�r6rhrmrCr�ryr8r8r9r�qs�zLoggerAdapter._logcC�|jjSrT�r�rur�r8r8r9ru~�zLoggerAdapter.managercCs||j_dSrTr�rsr8r8r9ru�scCr�rT)r�rgr�r8r8r9rg�r�zLoggerAdapter.namecCs&|j}t|���}d|jj|j|fSr\)r�rr�r�r�rg)r�r�r6r8r8r9r��szLoggerAdapter.__repr__rT)NNF)r�r�r�r�r�r�rr"r(r'rrrr#r�r.r�r�r�rErur�rgr�r8r8r8r9rs0
776  	
777  
778  
779  
780  rcKs�t�z�|�dd�}|�dd�}|�dd�}|r+tjdd�D]}t�|�|��qttj�dkr�|�dd�}|durId	|vrHd
781  |vrHtd��nd	|vsQd
782  |vrUtd��|dur�|�d
783  d�}|�d
d�}|r|d|vrnd}nt�	|�}t
784  ||||d�}n
785  |�d	d�}t|�}|g}|�dd�}	|�dd�}
786  |
787  tvr�tdd�
t�����|�dt|
788  d�}t||	|
789  �}|D]}|jdur�|�|�t�|�q�|�dd�}
|
dur�t�|
�|r�d�
|���}td|��Wt�dSWt�dSt�w)a9

790      Do basic configuration for the logging system.
791  
792      This function does nothing if the root logger already has handlers
793      configured, unless the keyword argument *force* is set to ``True``.
794      It is a convenience method intended for use by simple scripts
795      to do one-shot configuration of the logging package.
796  
797      The default behaviour is to create a StreamHandler which writes to
798      sys.stderr, set a formatter using the BASIC_FORMAT format string, and
799      add the handler to the root logger.
800  
801      A number of optional keyword arguments may be specified, which can alter
802      the default behaviour.
803  
804      filename  Specifies that a FileHandler be created, using the specified
805                filename, rather than a StreamHandler.
806      filemode  Specifies the mode to open the file, if filename is specified
807                (if filemode is unspecified, it defaults to 'a').
808      format    Use the specified format string for the handler.
809      datefmt   Use the specified date/time format.
810      style     If a format string is specified, use this to specify the
811                type of format string (possible values '%', '{', '$', for
812                %-formatting, :meth:`str.format` and :class:`string.Template`
813                - defaults to '%').
814      level     Set the root logger level to the specified level.
815      stream    Use the specified stream to initialize the StreamHandler. Note
816                that this argument is incompatible with 'filename' - if both
817                are present, 'stream' is ignored.
818      handlers  If specified, this should be an iterable of already created
819                handlers, which will be added to the root handler. Any handler
820                in the list which does not have a formatter assigned will be
821                assigned the formatter created in this function.
822      force     If this keyword  is specified as true, any existing handlers
823                attached to the root logger are removed and closed, before
824                carrying out the configuration as specified by the other
825                arguments.
826      encoding  If specified together with a filename, this encoding is passed to
827                the created FileHandler, causing it to be used when the file is
828                opened.
829      errors    If specified together with a filename, this value is passed to the
830                created FileHandler, causing it to be used when the file is
831                opened in text mode. If not specified, the default value is
832                `backslashreplace`.
833  
834      Note that you could specify a stream created using open(filename, mode)
835      rather than passing the filename and mode in. However, it should be
836      remembered that StreamHandler does not close its stream (since it may be
837      using sys.stdout or sys.stderr), whereas FileHandler closes its stream
838      when the handler is closed.
839  
840      .. versionchanged:: 3.2
841         Added the ``style`` parameter.
842  
843      .. versionchanged:: 3.3
844         Added the ``handlers`` parameter. A ``ValueError`` is now thrown for
845         incompatible arguments (e.g. ``handlers`` specified together with
846         ``filename``/``filemode``, or ``filename``/``filemode`` specified
847         together with ``stream``, or ``handlers`` specified together with
848         ``stream``.
849  
850      .. versionchanged:: 3.8
851         Added the ``force`` parameter.
852  
853      .. versionchanged:: 3.9
854         Added the ``encoding`` and ``errors`` parameters.
855      �forceFrRNrT�backslashreplacerrrFrtz8'stream' and 'filename' should not be specified togetherzG'stream' or 'filename' should not be specified together with 'handlers'�filemoderLrMrYr�r�r�r�r�r�rbr6z, zUnrecognised argument(s): %s)r:�poprlrr�r�rirJr�rSr
856  rr�r�r�rr"r4r�r.r;)r�r�rRrT�hrrtrQrF�dfsr��fsr�r6r�r8r8r9r�shF
857  
858  �
859  ��
860  
861  
862  �
863  *�rcCs(|rt|t�r|tjkrtStj�|�S)z�
864      Return a logger with the specified name, creating it if necessary.
865  
866      If no name is specified, return the root logger.
867      )rGrIrlrgrrur )rgr8r8r9r sr cO�0ttj�dkr
868  t�tj|g|�Ri|��dS)z�
869      Log a message with severity 'CRITICAL' on the root logger. If the logger
870      has no handlers, call basicConfig() to add a console handler with a
871      pre-defined format.
872      rN)rirlrrr�rhrmr�r8r8r9r!�rcOst|g|�Ri|��dS)z:
873      Don't use this function, use critical() instead.
874      Nr�r�r8r8r9r+srcOr�)z�
875      Log a message with severity 'ERROR' on the root logger. If the logger has
876      no handlers, call basicConfig() to add a console handler with a pre-defined
877      format.
878      rN)rirlrrrr�r8r8r9r1r�rr�cOst|g|�Rd|i|��dS)z�
879      Log a message with severity 'ERROR' on the root logger, with exception
880      information. If the logger has no handlers, basicConfig() is called to add
881      a console handler with a pre-defined format.
882      rCNr�)rhrCrmr�r8r8r9r;srcOr�)z�
883      Log a message with severity 'WARNING' on the root logger. If the logger has
884      no handlers, call basicConfig() to add a console handler with a pre-defined
885      format.
886      rN)rirlrrr(r�r8r8r9r(Cr�r(cOs(t�dtd�t|g|�Ri|��dS)Nz8The 'warn' function is deprecated, use 'warning' insteadrAr�r�r8r8r9r'Ms�r'cOr�)z�
887      Log a message with severity 'INFO' on the root logger. If the logger has
888      no handlers, call basicConfig() to add a console handler with a pre-defined
889      format.
890      rN)rirlrrr"r�r8r8r9r"Rr�r"cOr�)z�
891      Log a message with severity 'DEBUG' on the root logger. If the logger has
892      no handlers, call basicConfig() to add a console handler with a pre-defined
893      format.
894      rN)rirlrrrr�r8r8r9r\r�rcOs2ttj�dkr
895  t�tj||g|�Ri|��dS)z�
896      Log 'msg % args' with the integer severity 'level' on the root logger. If
897      the logger has no handlers, call basicConfig() to add a console handler
898      with a pre-defined format.
899      rN)rirlrrr#)r6rhrmr�r8r8r9r#fsr#cCs|tj_tj��dS)zB
900      Disable all logging calls of severity 'level' and below.
901      N)rlrurr�)r6r8r8r9rpsrc
902  Cs�t|dd��D]7}z-|�}|r6z z|��|��|��Wnttfy*YnwW|��n|��wWqtr>�YqdS)z�
903      Perform any cleanup actions in the logging system (e.g. flushing
904      buffers).
905  
906      Should be called at application exit.
907      N)�reversedrPr5r�r@rJrQr,)�handlerListrr�r8r8r9r&ws&�����r&c@r)ra�
908      This handler does nothing. It's intended to be used to avoid the
909      "No handlers could be found for logger XXX" one-off warning. This is
910      important for library code, which may contain code to log events. If a user
911      of the library does not configure logging, the one-off warning might be
912      produced; to avoid this, the library developer simply needs to instantiate
913      a NullHandler and add it to the top-level logger of the library module or
914      package.
915      cCr�zStub.Nr8r�r8r8r9r2��zNullHandler.handlecCrr�r8r�r8r8r9r1�r�zNullHandler.emitcCs
916  d|_dSrT)r+r�r8r8r9r$�s
917  zNullHandler.createLockcCrSrTr8r�r8r8r9r[�rXzNullHandler._at_fork_reinitN)r�r�r�r�r2r1r$r[r8r8r8r9r�s	rcCsf|durtdurt||||||�dSdSt�|||||�}td�}|js+|�t��|�d|�dS)a�
918      Implementation of showwarnings which redirects to logging, which will first
919      check to see if the file parameter is None. If a file is specified, it will
920      delegate to the original warnings implementation of showwarning. Otherwise,
921      it will call warnings.formatwarning and will log the resulting string to a
922      warnings logger named "py.warnings" with level logging.WARNING.
923      Nzpy.warningsz%s)�_warnings_showwarningr��
formatwarningr rr�rr()r�categoryrtrzr7�liner�r�r8r8r9�_showwarning�s�r�cCs:|rtdurtjatt_dSdStdurtt_dadSdS)z�
924      If capture is true, redirect all warnings to the logging package.
925      If capture is False, ensure that warnings are not redirected to logging
926      but to their original destinations.
927      N)r�r��showwarningr�)�capturer8r8r9r�s
928  ��rrTr�)or�r?rqrfr�r�r�r�r�collections.abcrj�stringrr�StrFormatter�__all__r��
929  __author__�
930  __status__�__version__�__date__r~r,r�r�r�rr	rrrr
rrr3r5rrr�rFrrr��__code__r<r�rMr*rOr:r;rW�WeakSetrYr^rR�objectrr�r*r)r$r�r�r�r�rr�rrrr�WeakValueDictionaryr(rrr rrr
931  r]�_defaultLastResortr+rar%r!rkrr�rirrlrurr rrrrr(r'r"rr#rr&�atexit�registerrr�r�rr8r8r8r9�<module>s�H	
932  	
�	�
933  
934  	
935  
936  
937  �	g
938  !"#�3*%4
939  CSU
h

940  
941  
942  
943  
944  
945  
946  
947  
948  
949