+
    Dfj?                        R t ^ RIHt ^ RIHt ^ RIHt ^ RIHtHtH	t	H
t
HtHt ^ RIHt ^ RIHt ^RIHtHt ^RIHtHt  ! R	 R
]4      t ! R R4      t ! R R4      t ! R R4      t]! 4       tR R ltR# )z
Logger class.
)annotations)time)TracebackType)AnyCallableContextManagerOptionalProtocolcast)currentframe)Failure)ILogObserverLogTrace)InvalidLogLevelErrorLogLevelc                  \    ] tR t^tRt]R R l4       t]R R l4       t]R R l4       tRt	R	# )
	Operationz
An L{Operation} represents the success (or lack thereof) of code performed
within the body of the L{Logger.failureHandler} context manager.
c                   V ^8  d   QhRR/#    returnbool )formats   "8/usr/lib/python3/dist-packages/twisted/logger/_logger.py__annotate__Operation.__annotate__   s      4     c                    R# )z
Did the operation succeed?  C{True} iff the code completed without
raising an exception; C{False} while the code is running and C{False}
if it raises an exception.
Nr   selfs   &r   	succeededOperation.succeeded       r   c                   V ^8  d   QhRR/# )r   r   Failure | Noner   )r   s   "r   r   r   $   s       r   c                    R# )zR
Did the operation raise an exception?  If so, this L{Failure} is that
exception.
Nr   r   s   &r   failureOperation.failure#   r#   r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r   +   s       r   c                    R# )z
Did the operation fail?  C{True} iff the code raised an exception;
C{False} while the code is running and C{False} if it completed without
error.
Nr   r   s   &r   failedOperation.failed*   r#   r   r   N)
__name__
__module____qualname____firstlineno____doc__propertyr!   r'   r+   __static_attributes__r   r   r   r   r      sC    
      r   r   c                  n    ] tR t^3t$ RtR]R&   RtR]R&   R R lt]R	 R
 l4       t	R R lt
R R ltRtR# )_FailCtxMgrFr   r!   Nr%   r'   c                    V ^8  d   QhRRRR/# r   failzCallable[[Failure], None]r   Noner   )r   s   "r   r   _FailCtxMgr.__annotate__7         6 4 r   c                	    Wn         R # N_failr    r8   s   &&r   __init___FailCtxMgr.__init__7       
r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r:   ;   s     ( ( (r   c                	    V P                   R J# r=   r'   r   s   &r   r+   _FailCtxMgr.failed:   s    ||4''r   c                   V ^8  d   QhRR/# )r   r   r   r   )r   s   "r   r   r:   >   s      9 r   c                	    V # r=   r   r   s   &r   	__enter___FailCtxMgr.__enter__>   s    r   c               (    V ^8  d   QhRRRRRRRR/# 	r   exc_typeztype[BaseException] | None	exc_valuezBaseException | None	tracebackzTracebackType | Noner   r   r   )r   s   "r   r   r:   A   s2      , ( (	 
r   c               	b    Ve$   \        4       pW@n        V P                  V4       R# RV n        R# NT)r   r'   r?   r!   r    rN   rO   rP   r'   s   """" r   __exit___FailCtxMgr.__exit__A   s3     iG"LJJw  "DNr   )r?   r'   r!   )r-   r.   r/   r0   r!   __annotations__r'   rA   r2   r+   rJ   rT   r3   r   r   r   r5   r5   3   s>    It"G^" ( ( r   r5   c                  :    ] tR t^QtR R ltR R ltR R ltRtR# )	_FastFailCtxMgrc                    V ^8  d   QhRRRR/# r7   r   )r   s   "r   r   _FastFailCtxMgr.__annotate__R   r;   r   c                	    Wn         R # r=   r>   r@   s   &&r   rA   _FastFailCtxMgr.__init__R   rC   r   c                   V ^8  d   QhRR/# )r   r   r9   r   )r   s   "r   r   rZ   U   s      4 r   c                	    R # r=   r   r   s   &r   rJ   _FastFailCtxMgr.__enter__U   s    r   c               (    V ^8  d   QhRRRRRRRR/# rM   r   )r   s   "r   r   rZ   X   s2      , ( (	 
r   c               	P    Ve"   \        4       pW@n        V P                  V4       R# rR   )r   r'   r?   rS   s   """" r   rT   _FastFailCtxMgr.__exit__X   s%     iG"LJJwr   )r?   r'   N)r-   r.   r/   r0   rA   rJ   rT   r3   r   r   r   rX   rX   Q   s     r   rX   c                  0   ] tR t^ftRt]R R l4       tRR R lltRR R lltR	 R
 lt	RR R llt
R]P                  3R R lltRR R lltRR R lltRR R lltRR R lltRR R llt]P                  3R R llt]P                  3R R lltRtR# ) Loggerab  
A L{Logger} emits log messages to an observer.  You should instantiate it
as a class or module attribute, as documented in L{this module's
documentation <twisted.logger>}.

@ivar namespace: the namespace for this logger
@ivar source: The object which is emitting events via this logger
@ivar observer: The observer that this logger will send events to.
c                   V ^8  d   QhRR/# r   r   strr   )r   s   "r   r   Logger.__annotate__r   s     	 	# 	r   c                 |     \        \        \        ^4      P                  R,          4      #   \         d     R# i ; i)z{
Derive a namespace from the module containing the caller's caller.

@return: the fully qualified python name of a module.
r-   z	<unknown>)r
   rg   r   	f_globalsKeyErrorr   r   r   _namespaceFromCallingContext#Logger._namespaceFromCallingContextq   s5    	\!_66zBCC 		s   ), ;;Nc               (    V ^8  d   QhRRRRRRRR/# )	r   	namespaceOptional[str]sourcezOptional[object]observerzOptional['ILogObserver']r   r9   r   )r   s   "r   r   rh   }   s2     % % % !% +	%
 
%r   c                v    Vf   V P                  4       pWn        W n        Vf   ^RIHp W@n        R# W0n        R# )a  
@param namespace: The namespace for this logger.  Uses a dotted
    notation, as used by python modules.  If not L{None}, then the name
    of the module of the caller is used.
@param source: The object which is emitting events via this
    logger; this is automatically set on instances of a class
    if this L{Logger} is an attribute of that class.
@param observer: The observer that this logger will send events to.
    If L{None}, use the L{global log publisher <globalLogPublisher>}.
N)globalLogPublisher)rl   ro   rq   _globalrt   rr   )r    ro   rq   rr   rt   s   &&&& r   rA   Logger.__init__}   s5      99;I"3*<M$Mr   c               $    V ^8  d   QhRRRRRR/# )r   instanceobjectownerzOptional[type]r   z'Logger'r   )r   s   "r   r   rh      s!     
 
 
~ 
 
r   c                    Vf   Q hVf   TpMTpV P                  RP                  VP                  VP                  .4      VV P                  R7      # )a  
When used as a descriptor, i.e.::

    # File: athing.py
    class Something:
        log = Logger()
        def hello(self):
            self.log.info("Hello")

a L{Logger}'s namespace will be set to the name of the class it is
declared on.  In the above example, the namespace would be
C{athing.Something}.

Additionally, its source will be set to the actual object referring to
the L{Logger}.  In the above example, C{Something.log.source} would be
C{Something}, and C{Something().log.source} would be an instance of
C{Something}.
.)rr   )	__class__joinr.   r-   rr   )r    rx   rz   rq   s   &&& r   __get__Logger.__get__   s[    &    FF~~HHe&&78]]  
 	
r   c                   V ^8  d   QhRR/# rf   r   )r   s   "r   r   rh      s     A A# Ar   c                	R    R V P                   P                   RV P                  : R2# )< >)r}   r-   ro   r   s   &r   __repr__Logger.__repr__   s'    4>>**+1T^^,>a@@r   c               (    V ^8  d   QhRRRRRRRR/# )	r   levelr   r   rp   kwargsry   r   r9   r   )r   s   "r   r   rh      s,     % %%'4%GM%	%r   c           	        V\         P                  ! 4       9  d*   V P                  R\        \	        V4      4      VV R7       R# TpVP                  V VV P                  V P                  V\        4       R7       RV9   d2   \        \        VR,          4      P                  W P                  34       V P                  V4       R# )a  
Emit a log event to all log observers at the given level.

@param level: a L{LogLevel}
@param format: a message format using new-style (PEP 3101)
    formatting.  The logging event (which is a L{dict}) is
    used to render this format string.
@param kwargs: additional key/value pairs to include in the event.
    Note that values which are later mutated may result in
    non-deterministic behavior from observers that schedule work for
    later execution.
z:Got invalid log level {invalidLevel!r} in {logger}.emit().)invalidLevelloggerN)
log_logger	log_levellog_namespace
log_source
log_formatlog_time	log_trace)r   iterconstantsr'   r   r   updatero   rq   r   r
   r   appendrr   )r    r   r   r   events   &&&, r   emitLogger.emit   s     ..00LLL,U34"	   ..{{V 	 	
 %5-.55t]]6KLer   c          
     ,    V ^8  d   QhRRRRRRRRR	R
/# )r   r   rg   r'   zOptional[Failure]r   r   r   ry   r   r9   r   )r   s   "r   r   rh      sC     5@ 5@5@ #5@ 	5@
 5@ 
5@r   c                L    Vf   \        4       pV P                  ! W13RV/VB  R# )au  
Log a failure and emit a traceback.

For example::

    try:
        frob(knob)
    except Exception:
        log.failure("While frobbing {knob}", knob=knob)

or::

    d = deferredFrob(knob)
    d.addErrback(lambda f: log.failure("While frobbing {knob}",
                                       f, knob=knob))

This method is meant to capture unexpected exceptions in code; an
exception that is caught and handled somehow should be logged, if
appropriate, via L{Logger.error} instead.  If some unknown exception
occurs and your code doesn't know how to handle it, as in the above
example, then this method provides a means to describe the failure.
This is done at L{LogLevel.critical} by default, since no corrective
guidance can be offered to an user/administrator, and the impact of the
condition is unknown.

@param format: a message format using new-style (PEP 3101) formatting.
    The logging event (which is a L{dict}) is used to render this
    format string.

@param failure: a L{Failure} to log.  If L{None}, a L{Failure} is
    created from the exception in flight.

@param level: a L{LogLevel} to use.

@param kwargs: additional key/value pairs to include in the event.
    Note that values which are later mutated may result in
    non-deterministic behavior from observers that schedule work for
    later execution.

@see: L{Logger.failureHandler}

@see: L{Logger.failuresHandled}
Nlog_failure)r   r   )r    r   r'   r   r   s   &&&&,r   r'   Logger.failure   s'    d ?iG		%?W??r   c               $    V ^8  d   QhRRRRRR/# r   r   rp   r   ry   r   r9   r   )r   s   "r   r   rh     !     4 4M 4F 4t 4r   c                J    V P                   ! \        P                  V3/ VB  R# )a  
Emit a log event at log level L{LogLevel.debug}.

@param format: a message format using new-style (PEP 3101) formatting.
    The logging event (which is a L{dict}) is used to render this
    format string.

@param kwargs: additional key/value pairs to include in the event.
    Note that values which are later mutated may result in
    non-deterministic behavior from observers that schedule work for
    later execution.
N)r   r   debugr    r   r   s   &&,r   r   Logger.debug       			(..&3F3r   c               $    V ^8  d   QhRRRRRR/# r   r   )r   s   "r   r   rh   *  !     3 3= 36 3d 3r   c                J    V P                   ! \        P                  V3/ VB  R# )a  
Emit a log event at log level L{LogLevel.info}.

@param format: a message format using new-style (PEP 3101) formatting.
    The logging event (which is a L{dict}) is used to render this
    format string.

@param kwargs: additional key/value pairs to include in the event.
    Note that values which are later mutated may result in
    non-deterministic behavior from observers that schedule work for
    later execution.
N)r   r   infor   s   &&,r   r   Logger.info*       			(--262r   c               $    V ^8  d   QhRRRRRR/# r   r   )r   s   "r   r   rh   9  r   r   c                J    V P                   ! \        P                  V3/ VB  R# )a  
Emit a log event at log level L{LogLevel.warn}.

@param format: a message format using new-style (PEP 3101) formatting.
    The logging event (which is a L{dict}) is used to render this
    format string.

@param kwargs: additional key/value pairs to include in the event.
    Note that values which are later mutated may result in
    non-deterministic behavior from observers that schedule work for
    later execution.
N)r   r   warnr   s   &&,r   r   Logger.warn9  r   r   c               $    V ^8  d   QhRRRRRR/# r   r   )r   s   "r   r   rh   H  r   r   c                J    V P                   ! \        P                  V3/ VB  R# )a  
Emit a log event at log level L{LogLevel.error}.

@param format: a message format using new-style (PEP 3101) formatting.
    The logging event (which is a L{dict}) is used to render this
    format string.

@param kwargs: additional key/value pairs to include in the event.
    Note that values which are later mutated may result in
    non-deterministic behavior from observers that schedule work for
    later execution.
N)r   r   errorr   s   &&,r   r   Logger.errorH  r   r   c               $    V ^8  d   QhRRRRRR/# r   r   )r   s   "r   r   rh   W  s!     7 7} 7v 7$ 7r   c                J    V P                   ! \        P                  V3/ VB  R# )a  
Emit a log event at log level L{LogLevel.critical}.

@param format: a message format using new-style (PEP 3101) formatting.
    The logging event (which is a L{dict}) is used to render this
    format string.

@param kwargs: additional key/value pairs to include in the event.
    Note that values which are later mutated may result in
    non-deterministic behavior from observers that schedule work for
    later execution.
N)r   r   criticalr   s   &&,r   r   Logger.criticalW  s     			(##V6v6r   c               (    V ^8  d   QhRRRRRRRR/# )	r   r   rg   r   r   r   ry   r   zContextManager[Operation]r   )r   s   "r   r   rh   f  s2     *O *O*O"**OJP*O	"*Or   c                .   a aaa \        VVVV 3R l4      # )a?  
Run some application code, logging a failure and emitting a traceback
in the event that any of it fails, but continuing on.  For example::

    log = Logger(...)

    def frameworkCode() -> None:
        with log.failuresHandled("While frobbing {knob}:", knob=knob) as op:
            frob(knob)
        if op.succeeded:
            log.info("frobbed {knob} successfully", knob=knob)

This method is meant to capture unexpected exceptions from application
code; an exception that is caught and handled somehow should be logged,
if appropriate, via L{Logger.error} instead.  If some unknown exception
occurs and your code doesn't know how to handle it, as in the above
example, then this method provides a means to describe the failure.
This is done at L{LogLevel.critical} by default, since no corrective
guidance can be offered to an user/administrator, and the impact of the
condition is unknown.

@param format: a message format using new-style (PEP 3101) formatting.
    The logging event (which is a L{dict}) is used to render this
    format string.

@param level: a L{LogLevel} to use.

@param kwargs: additional key/value pairs to include in the event, if
    it is emitted.  Note that values which are later mutated may result
    in non-deterministic behavior from observers that schedule work for
    later execution.

@see: L{Logger.failure}
@see: L{Logger.failureHandler}

@return: A context manager which yields an L{Operation} which will have
    either its C{succeeded} or C{failed} attribute set to C{True} upon
    completion of the code within the code within the C{with} block.
c                .   < SP                   ! SV S3/ SB # r=   rF   )fr   r   r   r    s   &r   <lambda>(Logger.failuresHandled.<locals>.<lambda>  s    T\\&!U%Mf%Mr   )r5   )r    r   r   r   s   ffflr   failuresHandledLogger.failuresHandledf  s    T MNNr   c               $    V ^8  d   QhRRRRRR/# )r   staticMessagerg   r   r   r   zContextManager[None]r   )r   s   "r   r   rh     s-     +P +P+P +P 
	+Pr   c                *   a aa \        VV V3R l4      # )a  
For performance-sensitive frameworks that needs to handle potential
failures from frequently-called application code, and do not need to
include detailed structured information about the failure nor inspect
the result of the operation, this method returns a context manager that
will log exceptions and continue, that can be shared across multiple
invocations.  It should be instantiated at module scope to avoid
additional object creations.

For example::

    log = Logger(...)
    ignoringFrobErrors = log.failureHandler("while frobbing:")

    def hotLoop() -> None:
        with ignoringFrobErrors:
            frob()

This method is meant to capture unexpected exceptions from application
code; an exception that is caught and handled somehow should be logged,
if appropriate, via L{Logger.error} instead.  If some unknown exception
occurs and your code doesn't know how to handle it, as in the above
example, then this method provides a means to describe the failure in
nerd-speak.  This is done at L{LogLevel.critical} by default, since no
corrective guidance can be offered to an user/administrator, and the
impact of the condition is unknown.

@param format: a message format using new-style (PEP 3101) formatting.
    The logging event (which is a L{dict}) is used to render this
    format string.

@param level: a L{LogLevel} to use.

@see: L{Logger.failure}

@return: A context manager which does not return a value, but will
    always exit from exceptions.
c                *   < SP                  SV S4      # r=   rF   )r   r   r    r   s   &r   r   'Logger.failureHandler.<locals>.<lambda>  s    mQ)Nr   )rX   )r    r   r   s   fffr   failureHandlerLogger.failureHandler  s    V NOOr   )ro   rr   rq   )NNNr=   )r-   r.   r/   r0   r1   staticmethodrl   rA   r   r   r   r   r   r'   r   r   r   r   r   r   r3   r   r   r   rd   rd   f   s     	 	%:
@A%T &*"++	5@n43347  .6->->*O^ #+++P +Pr   rd   c                    V ^8  d   QhRRRR/# )r   objry   r   rd   r   )r   s   "r   r   r     s     , ,F ,v ,r   c                @    \         P                  W P                  4      # )z7
Get a L{Logger} instance attached to the given class.
)_logr   r}   )r   s   &r   
_loggerForr     s     <<]]++r   N)r1   
__future__r   r   typesr   typingr   r   r   r   r	   r
   twisted.python.compatr   twisted.python.failurer   _interfacesr   r   _levelsr   r   r   r5   rX   rd   r   r   r   r   r   <module>r      sd   
 #   J J . * / 3 < < *WP WPt
 x,r   