Ϫf&dZddlmZddlmZmZmZddlmZddlm Z ddl m Z m Z ddl mZmZGd d ZeZd Zy ) z Logger class. )time)AnyOptionalcast) currentframe)Failure) ILogObserverLogTrace)InvalidLogLevelErrorLogLevelc jeZdZdZedefdZ ddeedeededddfd Z dd ed ee ddfd Z defd Z dde deededdfdZde jfdedeede deddf dZddeededdfdZddeededdfdZddeededdfdZddeededdfdZddeededdfdZy)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 }. @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. returncn tttdjdS#t$rYywxYw)z Derive a namespace from the module containing the caller's caller. @return: the fully qualified python name of a module. __name__z )rstrr f_globalsKeyError8/usr/lib/python3/dist-packages/twisted/logger/_logger.py_namespaceFromCallingContextz#Logger._namespaceFromCallingContexts5 \!_66zBC C  s %( 44N namespacesourceobserverr cr||j}||_||_|ddlm}||_y||_y)a3 @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 }. Nr )globalLogPublisher)rrr_globalrr)selfrrrrs r__init__zLogger.__init__)s=  99;I"   3*)r'rr)r!s r__repr__zLogger.__repr__fs'4>>**+1T^^,>a@@rlevelformatkwargsc p|tjvr(|jdtt |||y|}|j |||j |j|td|vr.tt|dj||jf|j|y)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().) invalidLevelloggerN) log_logger log_level log_namespace log_source log_formatlog_time log_trace) r iterconstantsfailurerr updaterrrrr appendr)r!r0r1r2events remitz Logger.emitis ..0 0 LLL,U34"    ..{{V   %  5- . 5 5tT]]6K L err>c H| t}|j||fd|i|y)a2 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. N log_failure)rrB)r!r1r>r0r2s rr>zLogger.failures+V ?iG %?W??rc H|jtj|fi|y)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)rBr debugr!r1r2s rrFz Logger.debug  (..&3F3rc H|jtj|fi|y)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)rBr inforGs rrJz Logger.info  (--262rc H|jtj|fi|y)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)rBr warnrGs rrMz Logger.warnrKrc H|jtj|fi|y)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)rBr errorrGs rrOz Logger.errorrHrc H|jtj|fi|y)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)rBr criticalrGs rrQzLogger.criticals  (##V6v6r)NNNN)rr) __qualname____doc__ staticmethodrrrobjectr"typer*r/r rBrQrr>rFrJrMrOrrrrrs #  $(#'-1 %C=% %>* %  %:  x~  @A#A8<%%'/}%GM% %T&*"++ .@.@'".@ .@  .@  .@` 4HSM 4F 4t 4 38C= 36 3d 3 38C= 36 3d 3 4HSM 4F 4t 4 7x} 7v 7$ 7rrcBtj||jSrR)_logr*r')objs rr[ sc3==9rN)rTrtypingrrrtwisted.python.compatrtwisted.python.failurer _interfacesr r _levelsr r rrY _loggerForrrrrbs< &&.*/3w7w7tx 9 r