MOON
Server: Apache
System: Linux vps.erhabenn.com.br 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64
User: sonne (1011)
PHP: 8.2.31
Disabled: NONE
Upload Files
File: //usr/lib/python2.7/site-packages/azurelinuxagent/common/logger.pyo
�
d�bc@sdZddlZddlmZmZddlmZddlmZedd�Zedd	�Z	edd
�Z
edd�Zedd�Zedd
�Z
edd�Zdefd��YZdefd��YZdefd��YZdefd��YZdefd��YZdefd��YZe�Zdefd��YZdefd��YZejdd�Zd�Zd �Zd!�Zd"�Zd#�Z d$�Z!d%�Z"d&�Z#d'�Z$d(�Z%d)�Z&d*�Z'd+�Z(ejdd,�Z)dS(-s
Log utils
i����N(tdatetimet	timedelta(t
currentThread(tustrtdaysithoursiitminutesiitLoggercBs�eZdZdZddd�Zd�Zd�Zd�Zd�Z	d�Z
d�Zd	�Zd
�Z
d�Zd�Zd
�Zd�Zd�Zd�Zd�Zd�ZRS(s
    Logger class
    u%Y-%m-%dT%H:%M:%S.%fZcCs:g|_|dkr|n||_i|_||_dS(N(t	appenderstNonetloggertperiodic_messagestprefix(tselfR
R((sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/logger.pyt__init__+s		cCsi|j_dS(N(R
R(R
((sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/logger.pytreset_periodic1scCs
||_dS(N(R(R
R((sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/logger.pyt
set_prefix4scCs0||jjkp/|jj||tj�kS(N(R
RRtnow(R
tdeltath((sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/logger.pyt_is_period_elapsed7scGsHt|�}|j||�rD|||�tj�|jj|<ndS(N(thashRRRR
R(R
Rtlog_level_opt
msg_formattargsR((sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/logger.pyt	_periodic;s
cGs|j||j||�dS(N(Rtinfo(R
RRR((sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/logger.pyt
periodic_infoAscGs|j||j||�dS(N(Rtverbose(R
RRR((sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/logger.pytperiodic_verboseDscGs|j||j||�dS(N(Rtwarn(R
RRR((sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/logger.pyt
periodic_warnGscGs|j||j||�dS(N(Rterror(R
RRR((sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/logger.pytperiodic_errorJscGs|jtj||�dS(N(tlogtLogLeveltVERBOSE(R
RR((sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/logger.pyRMscGs|jtj||�dS(N(R"R#tINFO(R
RR((sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/logger.pyRPscGs|jtj||�dS(N(R"R#tWARNING(R
RR((sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/logger.pyRSscGs|jtj||�dS(N(R"R#tERROR(R
RR((sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/logger.pyR Vsc
s^��fd�}t|�tk	r9t|dd�}nt|�dkr]|j|�}n|}tj�jtj�}t	j
�}t�j�}|j
dk	r�dj||||j
|��ndj||||��t�jdd�dd��x!|jD]}	|	j���qW|j|krZx'|jjD]}	|	j���q=WndS(	Ncs:|js6zt|_|j���Wdt|_XndS(sA
            The appender_lock flag is used to signal if the logger is currently in use. This prevents a subsequent log
            coming in due to writing of a log statement to be not written.

            Eg:
            Assuming a logger with two appenders - FileAppender and TelemetryAppender. Here is an example of
            how using appender_lock flag can help.

            logger.warn("foo")
                |- log.warn() (azurelinuxagent.common.logger.Logger.warn)
                    |- log() (azurelinuxagent.common.logger.Logger.log)
                        |- FileAppender.appender_lock is currently False not log_appender.appender_lock is True
                            |- We sets it to True.
                        |- FileAppender.write completes.
                        |- FileAppender.appender_lock sets to False.
                        |- TelemetryAppender.appender_lock is currently False not log_appender.appender_lock is True
                            |- We sets it to True.
                    [A] |- TelemetryAppender.write gets called but has an error and writes a log.warn("bar")
                            |- log() (azurelinuxagent.common.logger.Logger.log)
                            |- FileAppender.appender_lock is set to True (log_appender.appender_lock was false when entering).
                            |- FileAppender.write completes.
                            |- FileAppender.appender_lock sets to False.
                            |- TelemetryAppender.appender_lock is already True, not log_appender.appender_lock is False
                            Thus [A] cannot happen again if TelemetryAppender.write is not getting called. It prevents
                            faulty appenders to not get called again and again.

            :param log_appender: Appender
            :return: None
            N(t
appender_locktTruetwritetFalse(tlog_appender(tleveltlog_item(sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/logger.pyt	write_logZs
		terrorstbackslashreplaceiu{0} {1} {2} {3} {4}
u{0} {1} {2} {3}
tasciitencoding(ttypeRtlentformatRtutcnowtstrftimeRtLogTimeFormatInUTCR#tSTRINGSRtgetNameRR	tencodeRR*R
(
R
R-RRR/tmsgttimet	level_strtthread_nametappender((R-R.sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/logger.pyR"Ys&&
!	cCs&t|||�}|jj|�dS(N(t_create_logger_appenderRtappend(R
t
appender_typeR-tpathRA((sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/logger.pytadd_appender�scCstd�|jD��S(se
        Returns True if the current list of appenders includes at least one ConsoleAppender
        css|]}t|t�VqdS(N(t
isinstancetConsoleAppender(t.0RA((sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/logger.pys	<genexpr>�s(tanyR(R
((sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/logger.pytconsole_output_enabled�scCs2g|jD]}t|t�s
|^q
|_dS(sQ
        Removes all ConsoleAppenders from the current list of appenders
        N(RRGRH(R
RA((sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/logger.pytdisable_console_output�sN(t__name__t
__module__t__doc__R9R	RRRRRRRRR!RRRR R"RFRKRL(((sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/logger.pyR#s&													K		tAppendercBseZd�Zd�ZRS(cCst|_||_dS(N(R+R(R-(R
R-((sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/logger.pyR�s	cCsdS(N((R
R-R=((sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/logger.pyR*�s(RMRNRR*(((sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/logger.pyRP�s	RHcBseZd�Zd�ZRS(cCs#tt|�j|�||_dS(N(tsuperRHRRE(R
R-RE((sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/logger.pyR�scCsV|j|krRy,t|jd��}|j|�WdQXWqRtk
rNqRXndS(Ntw(R-topenRER*tIOError(R
R-R=tconsole((sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/logger.pyR*�s
(RMRNRR*(((sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/logger.pyRH�s	tFileAppendercBseZd�Zd�ZRS(cCs#tt|�j|�||_dS(N(RQRVRRE(R
R-RE((sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/logger.pyR�scCsV|j|krRy,t|jd��}|j|�WdQXWqRtk
rNqRXndS(Nsa+(R-RSRER*RT(R
R-R=tlog_file((sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/logger.pyR*�s
(RMRNRR*(((sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/logger.pyRV�s	tStdoutAppendercBseZd�Zd�ZRS(cCstt|�j|�dS(N(RQRXR(R
R-((sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/logger.pyR�scCs>|j|kr:ytjj|�Wq:tk
r6q:XndS(N(R-tsyststdoutR*RT(R
R-R=((sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/logger.pyR*�s

(RMRNRR*(((sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/logger.pyRX�s	tTelemetryAppendercBseZd�Zd�ZRS(cCs#tt|�j|�||_dS(N(RQR[Rt
event_func(R
R-R\((sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/logger.pyR�scCs>|j|kr:y|j||�Wq:tk
r6q:XndS(N(R-R\RT(R
R-R=((sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/logger.pyR*�s

(RMRNRR*(((sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/logger.pyR[�s	R#cBs2eZdZdZdZdZddddgZRS(iiiiR$R%R&R'(RMRNR$R%R&R'R:(((sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/logger.pyR#�stAppenderTypecBs eZdZdZdZdZRS(iiii(RMRNtFILEtCONSOLEtSTDOUTt	TELEMETRY(((sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/logger.pyR]scCstj|||�dS(N(tDEFAULT_LOGGERRF(RDR-RE((sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/logger.pytadd_logger_appenderscCs
tj�S(N(RbRK(((sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/logger.pyRKscCstj�dS(N(RbRL(((sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/logger.pyRLscCstj�dS(N(RbR(((sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/logger.pyRscCstj|�dS(N(RbR(R((sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/logger.pyRscGstj|||�dS(s�
    The hash-map maintaining the state of the logs gets reset here -
    azurelinuxagent.ga.monitor.MonitorHandler.reset_loggers. The current time period is defined by RESET_LOGGERS_PERIOD.
    N(RbR(RRR((sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/logger.pyRscGstj|||�dS(s�
    The hash-map maintaining the state of the logs gets reset here -
    azurelinuxagent.ga.monitor.MonitorHandler.reset_loggers. The current time period is defined by RESET_LOGGERS_PERIOD.
    N(RbR(RRR((sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/logger.pyR'scGstj|||�dS(s�
    The hash-map maintaining the state of the logs gets reset here -
    azurelinuxagent.ga.monitor.MonitorHandler.reset_loggers. The current time period is defined by RESET_LOGGERS_PERIOD.
    N(RbR!(RRR((sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/logger.pyR!/scGstj|||�dS(s�
    The hash-map maintaining the state of the logs gets reset here -
    azurelinuxagent.ga.monitor.MonitorHandler.reset_loggers. The current time period is defined by RESET_LOGGERS_PERIOD.
    N(RbR(RRR((sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/logger.pyR7scGstj||�dS(N(RbR(RR((sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/logger.pyR?scGstj||�dS(N(RbR(RR((sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/logger.pyRCscGstj||�dS(N(RbR(RR((sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/logger.pyRGscGstj||�dS(N(RbR (RR((sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/logger.pyR KscGstj|||�dS(N(RbR"(R-RR((sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/logger.pyR"OscCs}|tjkrt||�S|tjkr8t||�S|tjkrQt|�S|tjkrmt||�St	d��dS(NsUnknown appender type(
R]R_RHR^RVR`RXRaR[t
ValueError(RDR-RE((sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/logger.pyRBSs



(*RORYRRt	threadingRtazurelinuxagent.common.futureRt	EVERY_DAYtEVERY_HALF_DAYtEVERY_SIX_HOURSt
EVERY_HOURtEVERY_HALF_HOURtEVERY_FIFTEEN_MINUTEStEVERY_MINUTEtobjectRRPRHRVRXR[RbR#R]R%R	RcRKRLRRRRR!RRRRR R"RB(((sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/logger.pyt<module>sF�