B ÃÌ4]%ã@sŠdZddlZddlZe d¡Zejejkr6e ej¡dd„Z e ƒZ dd„Z Gdd „d e ƒZGd d „d e ƒZdd d „ZGdd„de ƒZdS)aˆLogging control and utilities. Control of logging for SA can be performed from the regular python logging module. The regular dotted module namespace is used, starting at 'sqlalchemy'. For class-level logging, the class name is appended. The "echo" keyword parameter, available on SQLA :class:`.Engine` and :class:`.Pool` objects, corresponds to a logger specific to that instance only. éNZ sqlalchemycCs*t tj¡}| t d¡¡| |¡dS)Nz.%(asctime)s %(levelname)s %(name)s %(message)s)ÚloggingZ StreamHandlerÚsysÚstdoutZ setFormatterZ FormatterZ addHandler)ÚloggerZhandler©rúA/opt/alt/python37/lib64/python3.7/site-packages/sqlalchemy/log.pyÚ_add_default_handler!s  rcsFt |jd|j¡‰‡fdd„|_‡fdd„|_ˆ|_t |¡|S)NÚ.cs ˆ tj¡S)N)Ú isEnabledForrÚDEBUG)Úself)rrrÚ.ózclass_logger..cs ˆ tj¡S)N)r rÚINFO)r )rrrr /r) rÚ getLoggerÚ __module__Ú__name__Ú_should_log_debugÚ_should_log_inforÚ_logged_classesÚadd)Úclsr)rrÚ class_logger,s  rc@s eZdZdZdd„Zdd„ZdS)Ú IdentifiedNcCs|j tj¡S)N)rr rr )r rrrr8szIdentified._should_log_debugcCs|j tj¡S)N)rr rr)r rrrr;szIdentified._should_log_info)rrÚ __qualname__Ú logging_namerrrrrrr5src@szeZdZdZejejejejdœZdd„Z dd„Z dd„Z d d „Z e Z d d „Zd d„Zdd„Zdd„Zdd„Zdd„ZdS)ÚInstanceLoggeraA logger adapter (wrapper) for :class:`.Identified` subclasses. This allows multiple instances (e.g. Engine or Pool instances) to share a logger, but have its verbosity controlled on a per-instance basis. The basic functionality is to return a logging level which is based on an instance's echo setting. Default implementation is: 'debug' -> logging.DEBUG True -> logging.INFO False -> Effective level of underlying logger ( logging.WARNING by default) None -> same as False )NFTÚdebugcCs8||_t |¡|_|j|tjkr4|jjs4t|jƒdS)N)ÚechorrrÚ _echo_maprZhandlersr)r rÚnamerrrÚ__init__Zs zInstanceLogger.__init__cOs|jtj|f|ž|ŽdS)z/Delegate a debug call to the underlying logger.N)Úlogrr )r ÚmsgÚargsÚkwargsrrrrfszInstanceLogger.debugcOs|jtj|f|ž|ŽdS)z/Delegate an info call to the underlying logger.N)r"rr)r r#r$r%rrrÚinfokszInstanceLogger.infocOs|jtj|f|ž|ŽdS)z1Delegate a warning call to the underlying logger.N)r"rZWARNING)r r#r$r%rrrÚwarningpszInstanceLogger.warningcOs|jtj|f|ž|ŽdS)zB Delegate an error call to the underlying logger. N)r"rÚERROR)r r#r$r%rrrÚerrorwszInstanceLogger.errorcOs"d|d<|jtj|f|ž|ŽdS)z4Delegate an exception call to the underlying logger.éÚexc_infoN)r"rr()r r#r$r%rrrÚ exception}szInstanceLogger.exceptioncOs|jtj|f|ž|ŽdS)z2Delegate a critical call to the underlying logger.N)r"rZCRITICAL)r r#r$r%rrrÚcriticalƒszInstanceLogger.criticalcOsR|jjj|krdS|j|j}|tjkr2|j ¡}||krN|jj|||f|ŽdS)zÎDelegate a log call to the underlying logger. The level here is determined by the echo flag as well as that of the underlying logger, and logger._log() is called directly. N) rÚmanagerÚdisablerrrÚNOTSETÚgetEffectiveLevelZ_log)r Úlevelr#r$r%Zselected_levelrrrr"ˆs    zInstanceLogger.logcCs|jjj|krdS|| ¡kS)z)Is this logger enabled for level 'level'?F)rr.r/r1)r r2rrrr žszInstanceLogger.isEnabledForcCs$|j|j}|tjkr |j ¡}|S)z+What's the effective level for this logger?)rrrr0rr1)r r2rrrr1¥s   z InstanceLogger.getEffectiveLevelN)rrrÚ__doc__rr0rr rr!rr&r'Úwarnr)r,r-r"r r1rrrrr?s   rcCsb|jr d|jj|jj|jf}nd|jj|jjf}||_|dkrNt |¡}n t||ƒ}||_dS)zEcreate a logger for an instance that implements :class:`.Identified`.z%s.%s.%sz%s.%s)FNN) rÚ __class__rrÚ_echorrrr)ÚinstanceÚechoflagr rrrrÚinstance_logger®s    r9c@s eZdZdZdd„Zdd„ZdS)Ú echo_propertya} When ``True``, enable log output for this element. This has the effect of setting the Python logging level for the namespace of this element's class and object reference. A value of boolean ``True`` indicates that the loglevel ``logging.INFO`` will be set for the logger, whereas the string value ``debug`` will set the loglevel to ``logging.DEBUG``. cCs|dkr |S|jSdS)N)r6)r r7ÚownerrrrÚ__get__×szecho_property.__get__cCst||ddS)N)r8)r9)r r7ÚvaluerrrÚ__set__Ýszecho_property.__set__N)rrrr3r<r>rrrrr:Ìs r:)N)r3rrrZ rootloggerr2r0ZsetLevelZWARNrÚsetrrÚobjectrrr9r:rrrrÚs     o