HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //proc/self/root/lib/python3/dist-packages/twisted/logger/__pycache__/_logger.cpython-38.pyc
U


W[6%�@sZdZddlmZddlmZddlmZddlmZmZGdd�de	�Z
e
�Zd	d
�ZdS)z
Logger class.
�)�time)�currentframe)�Failure�)�InvalidLogLevelError�LogLevelc@s�eZdZdZedd��Zddd�Zddd�Zd	d
�Zddd�Z	de
jfd
d�Zddd�Z
ddd�Zddd�Zddd�Zd dd�ZdS)!�Loggera�
    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>}.

    @type namespace: L{str}
    @ivar namespace: the namespace for this logger

    @type source: L{object}
    @ivar source: The object which is emitting events via this logger

    @type: L{ILogObserver}
    @ivar observer: The observer that this logger will send events to.
    cCs,ztd�jdWStk
r&YdSXdS)z�
        Derive a namespace from the module containing the caller's caller.

        @return: the fully qualified python name of a module.
        @rtype: L{str} (native string)
        ��__name__z	<unknown>N)r�	f_globals�KeyError�r
r
�8/usr/lib/python3/dist-packages/twisted/logger/_logger.py�_namespaceFromCallingContext!sz#Logger._namespaceFromCallingContextNcCsB|dkr|��}||_||_|dkr8ddlm}||_n||_dS)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.
        @type namespace: L{str} (native string)

        @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.
        @type source: L{object}

        @param observer: The observer that this logger will send events to.
            If L{None}, use the L{global log publisher <globalLogPublisher>}.
        @type observer: L{ILogObserver}
        Nr)�globalLogPublisher)r�	namespace�sourceZ_globalr�observer)�selfrrrrr
r
r�__init__/szLogger.__init__cCs2|dkr|}n|}|jd�|j|jg�||jd�S)a�
        When used as a descriptor, i.e.::

            # File: athing.py
            class Something(object):
                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}.
        N�.)r)�	__class__�join�
__module__r
r)rZoself�typerr
r
r�__get__Ls�zLogger.__get__cCsd|jj|jfS)Nz<%s %r>)rr
r)rr
r
r�__repr__kszLogger.__repr__cKst|t��kr*|jdtt|��||d�dS|}|j|||j|j|t�d�d|krf|d�	||j
f�|�
|�dS)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().)ZinvalidLevelZloggerN)Z
log_loggerZ	log_levelZ
log_namespaceZ
log_sourceZ
log_formatZlog_timeZ	log_trace)rZ
iterconstants�failurerr�updaterrr�appendr)r�level�format�kwargsZeventr
r
r�emitos(
��zLogger.emitcKs*|dkrt�}|j||fd|i|��dS)a
        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 generally 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 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 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.
        NZlog_failure)rr#)rr!rr r"r
r
rr�s(zLogger.failurecKs|jtj|f|�dS)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�rr!r"r
r
rr$�s
zLogger.debugcKs|jtj|f|�dS)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%r
r
rr&�s
zLogger.infocKs|jtj|f|�dS)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%r
r
rr'�s
zLogger.warncKs|jtj|f|�dS)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%r
r
rr(�s
zLogger.errorcKs|jtj|f|�dS)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%r
r
rr)s
zLogger.critical)NNN)N)N)N)N)N)N)N)r
r�__qualname__�__doc__�staticmethodrrrrr#rr)rr$r&r'r(r
r
r
rrs



$.



rcCst�||j�S)N)�_logrr)�objr
r
r�<lambda>�r/N)
r+rZtwisted.python.compatrZtwisted.python.failurerZ_levelsrr�objectrr-Z
_loggerForr
r
r
r�<module>s