
    h              
          % S r SSKrSSKJrJr  SSKJr  SSKJ	r	  SSK
Jr  SSKJr  SS	KJrJr  SS
KJr  \R&                  \R(                  \R*                  \R,                  \R.                  \R0                  \R2                  \R4                  \R6                  \R8                  0r\\	\4   \S'   S\\\	4   4S jr \ " 5       r!\" \5       " S S5      5       r" " S S5      r#g)z3
Integration with Python standard library logging.
    N)MappingTuple)implementer)NamedConstant)currentframe   )formatEvent)ILogObserverLogEvent)LogLeveltoStdlibLogLevelMappingreturnc                  |    0 n [         R                  5        H!  u  pXU'   X[        R                  " U5      '   M#     U $ )z
Reverse the above mapping, adding both the numerical keys used above and
the corresponding string keys also used by python logging.
@return: the reversed mapping
)r   itemsstdlibLogginggetLevelName)mappinglogLevel
pyLogLevels      ]/root/1688_scrapy/alibaba-scraper/venv/lib/python3.13/site-packages/twisted/logger/_stdlib.py_reverseLogLevelMappingr      sB     G 7 = = ?&
:B**:67 !@ N    c                   v    \ rS rSrSrSrS\4S\S\SS4S	 jjr SS
\	S\S\
\\\S4   4S jjrS\SS4S jrSrg)STDLibLogObserver/   a-  
Log observer that writes to the python standard library's C{logging}
module.

@note: Warning: specific logging configurations (example: network) can lead
    to this observer blocking.  Nothing is done here to prevent that, so be
    sure to not to configure the standard library logging module to block
    when used in conjunction with this module: code within Twisted, such as
    twisted.web, assumes that logging does not block.

@cvar defaultStackDepth: This is the default number of frames that it takes
    to get from L{STDLibLogObserver} through the logging module, plus one;
    in other words, the number of frames if you were to call a
    L{STDLibLogObserver} directly.  This is useful to use as an offset for
    the C{stackDepth} parameter to C{__init__}, to add frames for other
    publishers.
   twistedname
stackDepthr   Nc                 |    [         R                  " U5      U l        U R                  U R                  l        X l        g)zs
@param name: logger identifier.
@param stackDepth: The depth of the stack to investigate for caller
    metadata.
N)r   	getLoggerlogger_findCaller
findCallerr   )selfr   r   s      r   __init__STDLibLogObserver.__init__E   s-     $--d3!%!1!1$r   	stackInfo
stackLevelc                     [        U R                  5      nUR                  nSnUR                  UR                  UR
                  4U-   $ )a  
Based on the stack depth passed to this L{STDLibLogObserver}, identify
the calling function.

@param stackInfo: Whether or not to construct stack information.
    (Currently ignored.)
@param stackLevel: The number of stack frames to skip when determining
    the caller (currently ignored; use stackDepth on the instance).

@return: Depending on Python version, either a 3-tuple of (filename,
    lineno, name) or a 4-tuple of that plus stack information.
N)r   r   f_codeco_filenamef_linenoco_name)r%   r(   r)   fcoextras         r   r#   STDLibLogObserver._findCallerQ   s>     )XX

BJJ7%??r   eventc                 P   UR                  S[        R                  5      nUR                  S5      nUc  SnO'UR                  UR                  UR                  5       4n[        R                  U[        R                  5      nU R                  R                  U[        U5      US9  g)z2
Format an event and bridge it to Python logging.
	log_levellog_failureN)exc_info)getr   infotypevaluegetTracebackObjectr   r   INFOr"   logStringifiableFromEvent)r%   r4   levelfailureexcInfostdlibLevels         r   __call__STDLibLogObserver.__call__e   s     		+x}}5))M*?G||W]]G4N4N4PQG-11%9K9KL%;E%BWUr   )r"   r   )Fr   )__name__
__module____qualname____firstlineno____doc__defaultStackDepthstrintr&   boolr   r#   r   rE   __static_attributes__ r   r   r   r   /   s~    $  $7H
%
%14
%	
% :;@@36@	sCd"	#@(Vh V4 Vr   r   c                   F    \ rS rSrSrS\SS4S jrS\4S jrS\	4S jr
S	rg)
r@   s   zu
An object that implements C{__str__()} in order to defer the work of
formatting until it's converted into a C{str}.
r4   r   Nc                     Xl         g)z
@param event: An event.
Nr4   )r%   r4   s     r   r&   StringifiableFromEvent.__init__y   s	     
r   c                 ,    [        U R                  5      $ r+   )r	   r4   r%   s    r   __str__StringifiableFromEvent.__str__   s    4::&&r   c                 6    [        U 5      R                  S5      $ )Nzutf-8)rM   encoderX   s    r   	__bytes__ StringifiableFromEvent.__bytes__   s    4y((r   rU   )rG   rH   rI   rJ   rK   r   r&   rM   rY   bytesr]   rP   rQ   r   r   r@   r@   s   s2    
h 4 ' ')5 )r   r@   )$rK   loggingr   typingr   r   zope.interfacer   
constantlyr   twisted.python.compatr   _formatr	   _interfacesr
   r   _levelsr   debugDEBUGr:   r>   warnWARNINGerrorERRORcriticalCRITICALr   rN   __annotations__r   fromStdlibLogLevelMappingr   r@   rQ   r   r   <module>rr      s   
   ! & $ .   /  NNM''MM=%%MM=((NNM''}--8 !34 
m);!< 
 45  \@V @V @VF) )r   