Your IP : 3.131.37.82


Current Path : /usr/lib/python3.6/site-packages/dnf/__pycache__/
Upload File :
Current File : //usr/lib/python3.6/site-packages/dnf/__pycache__/logging.cpython-36.opt-1.pyc

3

�ft`r(�@s�ddlmZddlmZddlZddlZddlZddlZddlZ	ddl
Z
ddlZ
ddlZddl
Z
ddlZddlZddlZdZe
jZe
jZe
jZe
jZe
jZdZdZdZdZd	d
�ZGdd�de�Zee
je
je
je
je
je
jeeeed
�Zdd�Zee
je
jd�Z dd�Z!dd�Z"d%Z#dd�Z$Gdd�de
j%j&�Z'dd�Z(dd�Z)Gdd �d e�Z*Gd!d"�d"e�Z+e	j,j-j.ee	j,j-j/ee	j,j-j0ee	j,j-j1ee	j,j-j2ee	j,j-j3ee	j,j-j4eiZ5Gd#d$�d$e	j,j-�Z6e6�Z7e	j,j8j9e7�dS)&�)�absolute_import)�unicode_literalsN�d����csdd����fdd�}|S)zGMethod decorator turning the method into noop on second or later calls.c_sdS)N�)Z_argsZ_kwargsr	r	�/usr/lib/python3.6/logging.py�noop3szonly_once.<locals>.noopcs"�|f|�|�t|�j��dS)N)�setattr�__name__)�self�args�kwargs)�funcrr	r
�	swan_song5szonly_once.<locals>.swan_songr	)rrr	)rrr
�	only_once1src@seZdZdd�Zdd�ZdS)�_MaxLevelFiltercCs
||_dS)N)�	max_level)rrr	r	r
�__init__;sz_MaxLevelFilter.__init__cCs|j|jkrdSdS)Nr�)Zlevelnor)r�recordr	r	r
�filter>sz_MaxLevelFilter.filterN)r
�
__module__�__qualname__rrr	r	r	r
r:sr)rrr�r�r�r�	�
cCstj|t�S)N)�_VERBOSE_VAL_MAPPING�get�TRACE)�
cfg_errvalr	r	r
�_cfg_verbose_val2levelQsr%)rrrcCstj|tj�S)N)�_ERR_VAL_MAPPINGr"�logging�WARNING)r$r	r	r
�_cfg_err_val2level^sr)cCs|dS)Nz.gzr	)�namer	r	r
�compression_namercsr+�icCs\t|d��>}tj|d��&}x|jt�}|s,P|j|�qWWdQRXWdQRXtj|�dS)N�rb�wb)�open�gzip�read�
CHUNK_SIZE�write�os�remove)�source�destZsfZwf�datar	r	r
�compression_rotatorjs
"r9cs&eZdZd	�fdd�	Zdd�Z�ZS)
�MultiprocessRotatingFileHandler�arNFcs.tt|�j||||||�tjjdd�|_dS)Nz	/var/log/T)�superr:r�dnf�lockZbuild_log_lock�rotate_lock)r�filename�mode�maxBytes�backupCount�encodingZdelay)�	__class__r	r
rvs
z(MultiprocessRotatingFileHandler.__init__cCs�x�yR|j|�rD|j�*tj|j�j}|j�tj|j|�WdQRXtj	j
||�dStjj
tjjfk
r~tjd�Yqtk
r�|j|�dSXqWdS)Ng{�G�z�?)ZshouldRolloverr?r4�statZbaseFilename�st_modeZ
doRollover�chmodr'ZFileHandler�emitr=�
exceptionsZProcessLockErrorZThreadLockError�timeZsleep�	ExceptionZhandleError)rrrAr	r	r
rI{s

z$MultiprocessRotatingFileHandler.emit)r;rrNF)r
rrrrI�
__classcell__r	r	)rEr
r:usr:cCsltjj|�s,tjjtjj|��tjj|�t|||d�}t	j
dd�}tj|_
|j|�|rht|_t|_|S)N)rBrCz%%(asctime)s %(levelname)s %(message)sz%Y-%m-%dT%H:%M:%S%z)r4�path�existsr=�utilZ
ensure_dir�dirnameZtouchr:r'Z	FormatterrKZ	localtimeZ	converterZsetFormatterr9Zrotatorr+Znamer)�logfile�log_size�
log_rotate�log_compress�handlerZ	formatterr	r	r
�_create_filehandler�s
rWcCs|jttjj�dS)N)�log�INFOr=�constZ
LOG_MARKER)Zloggerr	r	r
�_paint_mark�sr[c@sBeZdZdd�Zedd��Zedd��Zedd��Zd
d
d�ZdS)�LoggingcCsPd|_|_tjtd�tjtd�tjtd�tjtd�tjd�dt_	dS)N�DDEBUG�SUBDEBUGr#�ALLTF)
�stdout_handler�stderr_handlerr'ZaddLevelNamer]r^r#r_ZcaptureWarningsZraiseExceptions)rr	r	r
r�s
zLogging.__init__cCsttjd�}|jt�tjtj�}|jt�|jt	tj
��|j|�||_tjtj
�}|jt
�|j|�||_dS)Nr=)r'�	getLogger�setLevelr#Z
StreamHandler�sys�stdoutrYZ	addFilterrr(�
addHandlerr`�stderrra)r�
logger_dnfrergr	r	r
�	_presetup�s





zLogging._presetupcCs�tjd�}|jt�tjj|tjj	�}t
||||�}|j|�|j|�tjd�}	|	j|�tjd�}
|
jt�tjj|tjj�}t
||||�}|
j|�t
jjj||tk�tjd�}d|_|jt�tjj|tjj�}t
||||�}|j|�dS)Nr=zpy.warnings�librepozdnf.rpmF)r'rbrcr#r4rN�joinr=rZZLOGrWrfZLOG_LIBREPO�libdnfZrepoZ
LibrepoLogr_Z	propagater^ZLOG_RPM)r�
logfile_level�logdirrSrTrUrhrRrV�logger_warningsZlogger_librepo�
logger_rpmr	r	r
�_setup_file_loggers�s(










zLogging._setup_file_loggerscCs�|j�|j|||||�tjd�}|j|j�tjd�}	|	j|j�|	j|j�tjd�}
|jjt�|jjt�t	|
�t	|	�|jj|�|jj|�dS)Nzpy.warningszdnf.rpmr=)
rirqr'rbrfrar`rcr(r[)rZ
verbose_levelZerror_levelrmrnrSrTrUrorprhr	r	r
�_setup�s


zLogging._setupFc
Csft|j�}t|j�}t|j�}|j}|j}|j}|j}	|rL|j	|||||	�S|j
|||||||	�SdS)N)r%Z
debuglevelr)Z
errorlevelZlogfilelevelrnrSrTrUrqrr)
rZconfZfile_loggers_onlyZverbose_level_rZ
error_level_rZlogfile_level_rrnrSrTrUr	r	r
�_setup_from_dnf_conf�s


zLogging._setup_from_dnf_confN)F)	r
rrrrrirqrrrsr	r	r	r
r\�s
	r\c@seZdZdd�Zdd�ZdS)�TimercCs||_tj�|_dS)N)�whatrK�start)rrur	r	r
rszTimer.__init__cCs6tj�|j}d|j|df}tjd�jt|�dS)Nztimer: %s: %d msi�r=)rKrvrur'rbrXr])rZdiff�msgr	r	r
�__call__szTimer.__call__N)r
rrrrxr	r	r	r
rtsrtcs$eZdZ�fdd�Zdd�Z�ZS)�LibdnfLoggerCBcs*tt|�j�tjd�|_tjd�|_dS)Nr=rj)r<ryrr'rb�_dnf_logger�_librepo_logger)r)rEr	r
rszLibdnfLoggerCB.__init__cGsft|�dkr|\}}nt|�dkr.|\}}}}|tjjjkrP|jjt||�n|jjt||�dS)zoLog message.

        source -- integer, defines origin (libdnf, librepo, ...) of message, 0 - unknown
        rrN)	�lenrl�utils�LoggerZLOG_SOURCE_LIBREPOr{rX�_LIBDNF_TO_DNF_LOGLEVEL_MAPPINGrz)rr6r�level�messagerK�pidr	r	r
r3s
zLibdnfLoggerCB.write)r
rrrr3rMr	r	)rEr
rysryi):Z
__future__rrZdnf.exceptionsr=Z	dnf.constZdnf.lockZdnf.utilZlibdnf.reporlr'Zlogging.handlersr4rdrK�warningsr0Z
SUPERCRITICALZCRITICALZERRORr(rY�DEBUGr]r^r#r_r�objectrr!r%r&r)r+r2r9ZhandlersZRotatingFileHandlerr:rWr[r\rtr}r~ZLevel_CRITICALZLevel_ERRORZ
Level_WARNINGZLevel_NOTICEZ
Level_INFOZLevel_DEBUGZLevel_TRACErryZlibdnfLoggerCBZLogZ	setLoggerr	r	r	r
�<module>sv	

a







?>