Sh3ll
OdayForums


Server : Apache
System : Linux server1.cgrithy.com 3.10.0-1160.95.1.el7.x86_64 #1 SMP Mon Jul 24 13:59:37 UTC 2023 x86_64
User : nobody ( 99)
PHP Version : 8.1.23
Disable Function : NONE
Directory :  /usr/lib/python2.7/site-packages/firewall/core/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //usr/lib/python2.7/site-packages/firewall/core/logger.pyo
�
�c�`c@sddddgZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z
ddl
Z
defd��YZdefd��YZ
d	e
fd
��YZdefd��YZdefd
��YZdefd��YZe�ZdS(t	LogTargettFileLogtLoggertlogi����NcBs5eZdZd�Zdd�Zd�Zd�ZRS(s% Abstract class for logging targets. cCs
d|_dS(N(tNonetfd(tself((s8/usr/lib/python2.7/site-packages/firewall/core/logger.pyt__init__(sicCstd��dS(Ns%LogTarget.write is an abstract method(tNotImplementedError(Rtdatatleveltloggertis_debug((s8/usr/lib/python2.7/site-packages/firewall/core/logger.pytwrite+scCstd��dS(Ns%LogTarget.flush is an abstract method(R(R((s8/usr/lib/python2.7/site-packages/firewall/core/logger.pytflush.scCstd��dS(Ns%LogTarget.close is an abstract method(R(R((s8/usr/lib/python2.7/site-packages/firewall/core/logger.pytclose1s(t__name__t
__module__t__doc__RR
RR(((s8/usr/lib/python2.7/site-packages/firewall/core/logger.pyR&s
		t
_StdoutLogcBs/eZd�Zdd�Zd�Zd�ZRS(cCstj|�tj|_dS(N(RRtsyststdoutR(R((s8/usr/lib/python2.7/site-packages/firewall/core/logger.pyR8s
icCs|jj|�|j�dS(N(RR
R(RR	R
RR((s8/usr/lib/python2.7/site-packages/firewall/core/logger.pyR
<scCs|j�dS(N(R(R((s8/usr/lib/python2.7/site-packages/firewall/core/logger.pyRAscCs|jj�dS(N(RR(R((s8/usr/lib/python2.7/site-packages/firewall/core/logger.pyRDs(RRRR
RR(((s8/usr/lib/python2.7/site-packages/firewall/core/logger.pyR7s		t
_StderrLogcBseZd�ZRS(cCstj|�tj|_dS(N(RRRtstderrR(R((s8/usr/lib/python2.7/site-packages/firewall/core/logger.pyRKs
(RRR(((s8/usr/lib/python2.7/site-packages/firewall/core/logger.pyRJst
_SyslogLogcBs/eZd�Zdd�Zd�Zd�ZRS(cCs=tj|�tjtjjtjd�tj	tj
�dS(Ni(RRtsyslogtopenlogtostpathtbasenameRtargvtLOG_PIDt
LOG_DAEMON(R((s8/usr/lib/python2.7/site-packages/firewall/core/logger.pyRSs
	icCs�d}|rtj}nl||jkr3tj}nQ||jkrNtj}n6||jkritj}n||j	kr�tj
}n|jd�r�|t|�d }nt|�dkr�|dkr�tj|�q�tj||�ndS(Ns
ii(
RRt	LOG_DEBUGtINFO1tLOG_INFOtWARNINGtLOG_WARNINGtERRORtLOG_ERRtFATALtLOG_CRITtendswithtlen(RR	R
RRtpriority((s8/usr/lib/python2.7/site-packages/firewall/core/logger.pyR
as"cCstj�dS(N(Rtcloselog(R((s8/usr/lib/python2.7/site-packages/firewall/core/logger.pyRwscCsdS(N((R((s8/usr/lib/python2.7/site-packages/firewall/core/logger.pyRzs(RRRR
RR(((s8/usr/lib/python2.7/site-packages/firewall/core/logger.pyRRs		cBsAeZdZdd�Zd�Zdd�Zd�Zd�ZRS(s< FileLog class.
    File will be opened on the first write. twcCs#tj|�||_||_dS(N(RRtfilenametmode(RR/R0((s8/usr/lib/python2.7/site-packages/firewall/core/logger.pyR�s
	cCs�|jr
dStjtjB}|jjd�r?|tjO}ntj|j|d�|_tj	|jd�tj
|j|j�|_tj|jtjtj
�dS(Ntai�(RRtO_CREATtO_WRONLYR0t
startswithtO_APPENDtopenR/tfchmodtfdopentfcntltF_SETFDt
FD_CLOEXEC(Rtflags((s8/usr/lib/python2.7/site-packages/firewall/core/logger.pyR6�s	icCs7|js|j�n|jj|�|jj�dS(N(RR6R
R(RR	R
RR((s8/usr/lib/python2.7/site-packages/firewall/core/logger.pyR
�s	
cCs'|js
dS|jj�d|_dS(N(RRR(R((s8/usr/lib/python2.7/site-packages/firewall/core/logger.pyR�s	
cCs|js
dS|jj�dS(N(RR(R((s8/usr/lib/python2.7/site-packages/firewall/core/logger.pyR�s	(RRRRR6R
RR(((s8/usr/lib/python2.7/site-packages/firewall/core/logger.pyRs	
	cBseZdZdZdZdZdZdZdZe	�Z
e�Ze
�Zddd	�Zd
�Zdd�Zdd
�Zdd�Zdd�Zd�Zd�Zd�Zd�Zd�Zd�Zed2d�Zed2d�Zed2d�Zed2d�Zed2d�Z ed2d�Z!d�Z"d�Z#d�Z$d�Z%d �Z&d!�Z'd"�Z(d#�Z)d$�Z*d%�Z+d&�Z,dd'�Z-d(�Z.dd)�Z/ed2dd*�Z0ed2dd+�Z1ed2dd,�Z2dd-�Z3d.�Z4d/�Z5d0�Z6dd1�Z7RS(3sL	
    Format string:

    %(class)s      Calling class the function belongs to, else empty
    %(date)s       Date using Logger.date_format, see time module
    %(domain)s     Full Domain: %(module)s.%(class)s.%(function)s
    %(file)s       Filename of the module
    %(function)s   Function name, empty in __main__
    %(label)s      Label according to log function call from Logger.label
    %(level)d      Internal logging level
    %(line)d       Line number in module
    %(module)s     Module name
    %(message)s    Log message

    Standard levels:

    FATAL                 Fatal error messages
    ERROR                 Error messages
    WARNING               Warning messages
    INFOx, x in [1..5]    Information
    DEBUGy, y in [1..10]  Debug messages
    NO_INFO               No info output
    NO_DEBUG              No debug output
    INFO_MAX              Maximum info level
    DEBUG_MAX             Maximum debug level

    x and y depend on info_max and debug_max from Logger class
    initialization. See __init__ function.

    Default logging targets:

    stdout        Logs to stdout
    stderr        Logs to stderr
    syslog        Logs to syslog

    Additional arguments for logging functions (fatal, error, warning, info
    and debug):

    nl       Disable newline at the end with nl=0, default is nl=1.
    fmt      Format string for this logging entry, overloads global format
             string. Example: fmt="%(file)s:%(line)d %(message)s"
    nofmt    Only output message with nofmt=1. The nofmt argument wins over
             the fmt argument.

    Example:

    from logger import log
    log.setInfoLogLevel(log.INFO1)
    log.setDebugLogLevel(log.DEBUG1)
    for i in range(1, log.INFO_MAX+1):
        log.setInfoLogLabel(i, "INFO%d: " % i)
    log.setFormat("%(date)s %(module)s:%(line)d [%(domain)s] %(label)s: "
                  "%(level)d %(message)s")
    log.setDateFormat("%Y-%m-%d %H:%M:%S")

    fl = FileLog("/tmp/log", "a")
    log.addInfoLogging("*", fl)
    log.addDebugLogging("*", fl)
    log.addInfoLogging("*", log.syslog, fmt="%(label)s%(message)s")

    log.debug3("debug3")
    log.debug2("debug2")
    log.debug1("debug1")
    log.info2("info2")
    log.info1("info1")
    log.warning("warning\n", nl=0)
    log.error("error\n", nl=0)
    log.fatal("fatal")
    log.info(log.INFO1, "nofmt info", nofmt=1)

    i����i����i����i����i����iii
cCs�i|_i|_d|_d|_i|_i|_i|_i|_i|_i|_	|dkryt
d|��n|dkr�t
d|��n|j|_||_
d|_||_|j|jd�|j|jd�|j|jd�|j|jd�xbtd|j
d�D]J}t|d	||�|j|d�t|d
|d�||��q"Wxftd|jd�D]N}t|d||�|j|d
|�t|d|d�||��q�W|j|j�|j|j�|jd�|jd�|jd|j|j|j|jg�|jd|jgt|j|j
d�D]}|^qd�|jd|jgtd|jd�D]}|^q��dS(s Logger class initialization tisLogger: info_max %d is too lowisLogger: debug_max %d is too lows
FATAL ERROR: sERROR: s	WARNING: sINFO%dsinfo%dcs��fd�S(Ncs�j�|||�S(N(tinfo(tmessagetargstkwargs(Rtx(s8/usr/lib/python2.7/site-packages/firewall/core/logger.pyt<lambda> s((RRB((RRBs8/usr/lib/python2.7/site-packages/firewall/core/logger.pyRCssDEBUG%ds	DEBUG%d: sdebug%dcs��fd�S(Ncs�j�|||�S(N(tdebug(R?R@RA(RRB(s8/usr/lib/python2.7/site-packages/firewall/core/logger.pyRC)s((RRB((RRBs8/usr/lib/python2.7/site-packages/firewall/core/logger.pyRC(ss%(label)s%(message)ss%d %b %Y %H:%M:%St*N( t_levelt_debug_levelt_formatt_date_formatt_labelt_debug_labelt_loggingt_debug_loggingt_domainst_debug_domainst
ValueErrorR$tNO_INFOtINFO_MAXtNO_DEBUGt	DEBUG_MAXtsetInfoLogLabelR(t	TRACEBACKR&trangetsetattrtsetDebugLogLabeltsetInfoLogLevelR"tsetDebugLogLevelt	setFormatt
setDateFormattsetInfoLoggingRRtsetDebugLogging(Rtinfo_maxt	debug_maxRFti((s8/usr/lib/python2.7/site-packages/firewall/core/logger.pyR�sX													




-cCshxat|j|jd�D]F}||jkr5qnx(|j|D]\}}}|j�qCWqWdS(s Close all logging targets iN(RWR(RTRLR(RR
tdummyttarget((s8/usr/lib/python2.7/site-packages/firewall/core/logger.pyR8s
 REcCs.|j|�||jkr'|j|S|jS(s Get info log level. (t_checkDomainRFtNOTHING(Rtdomain((s8/usr/lib/python2.7/site-packages/firewall/core/logger.pytgetInfoLogLevel@s
cCsT|j|�||jkr(|j}n||jkrC|j}n||j|<dS(s% Set log level [NOTHING .. INFO_MAX] N(ReRfRRRF(RR
Rg((s8/usr/lib/python2.7/site-packages/firewall/core/logger.pyRZGs
cCs5|j|�||jkr.|j||jS|jS(s Get debug log level. (ReRGRS(RRg((s8/usr/lib/python2.7/site-packages/firewall/core/logger.pytgetDebugLogLevelPs
cCsU|j|�|dkr"d}n||jkr=|j}n||j|j|<dS(s- Set debug log level [NO_DEBUG .. DEBUG_MAX] iN(ReRTRSRG(RR
Rg((s8/usr/lib/python2.7/site-packages/firewall/core/logger.pyR[Ws
	cCs|jS(N(RH(R((s8/usr/lib/python2.7/site-packages/firewall/core/logger.pyt	getFormat`scCs
||_dS(N(RH(RRH((s8/usr/lib/python2.7/site-packages/firewall/core/logger.pyR\cscCs|jS(N(RI(R((s8/usr/lib/python2.7/site-packages/firewall/core/logger.pyt
getDateFormatfscCs
||_dS(N(RI(RRH((s8/usr/lib/python2.7/site-packages/firewall/core/logger.pyR]iscCsP|j|�}x:|D]2}|j|d|jd|j�||j|<qWdS(sU Set log label for level. Level can be a single level or an array
        of levels. t	min_levelt	max_levelN(t
_getLevelst_checkLogLevelR(RRRJ(RR
tlabeltlevels((s8/usr/lib/python2.7/site-packages/firewall/core/logger.pyRUls


cCsV|j|dd�}x:|D]2}|j|d|jd|j�||j|<qWdS(sU Set log label for level. Level can be a single level or an array
        of levels. RiRlRmN(RnRoR"RTRK(RR
RpRq((s8/usr/lib/python2.7/site-packages/firewall/core/logger.pyRYus


cCs |j||||dd�dS(s� Set info log target for domain and level. Level can be a single
        level or an array of levels. Use level ALL to set for all levels.
        If no format is specified, the default format will be used. RiN(t_setLogging(RRgRdR
tfmt((s8/usr/lib/python2.7/site-packages/firewall/core/logger.pyR^~scCs |j||||dd�dS(s� Set debug log target for domain and level. Level can be a single
        level or an array of levels. Use level ALL to set for all levels.
        If no format is specified, the default format will be used. RiN(Rr(RRgRdR
Rs((s8/usr/lib/python2.7/site-packages/firewall/core/logger.pyR_�scCs |j||||dd�dS(s� Add info log target for domain and level. Level can be a single
        level or an array of levels. Use level ALL to set for all levels.
        If no format is specified, the default format will be used. RiN(t_addLogging(RRgRdR
Rs((s8/usr/lib/python2.7/site-packages/firewall/core/logger.pytaddInfoLogging�scCs |j||||dd�dS(s� Add debg log target for domain and level. Level can be a single
        level or an array of levels. Use level ALL to set for all levels.
        If no format is specified, the default format will be used. RiN(Rt(RRgRdR
Rs((s8/usr/lib/python2.7/site-packages/firewall/core/logger.pytaddDebugLogging�scCs |j||||dd�dS(s� Delete info log target for domain and level. Level can be a single
        level or an array of levels. Use level ALL to set for all levels.
        If no format is specified, the default format will be used. RiN(t_delLogging(RRgRdR
Rs((s8/usr/lib/python2.7/site-packages/firewall/core/logger.pytdelInfoLogging�scCs |j||||dd�dS(s� Delete debug log target for domain and level. Level can be a single
        level or an array of levels. Use level ALL to set for all levels.
        If no format is specified, the default format will be used. RiN(Rw(RRgRdR
Rs((s8/usr/lib/python2.7/site-packages/firewall/core/logger.pytdelDebugLogging�scCs|j|dd�S(sN Is there currently any info logging for this log level (and
        domain)? Ri(t_isLoggingHere(RR
((s8/usr/lib/python2.7/site-packages/firewall/core/logger.pytisInfoLoggingHere�scCs|j|dd�S(sO Is there currently any debug logging for this log level (and
        domain)? Ri(Rz(RR
((s8/usr/lib/python2.7/site-packages/firewall/core/logger.pytisDebugLoggingHere�scOs4|j|�d|d<|j|j|||�dS(s Fatal error log. iRN(t_checkKWargst_logR((RRHR@RA((s8/usr/lib/python2.7/site-packages/firewall/core/logger.pytfatal�s

cOs4|j|�d|d<|j|j|||�dS(s Error log. iRN(R}R~R&(RRHR@RA((s8/usr/lib/python2.7/site-packages/firewall/core/logger.pyterror�s

cOs4|j|�d|d<|j|j|||�dS(s Warning log. iRN(R}R~R$(RRHR@RA((s8/usr/lib/python2.7/site-packages/firewall/core/logger.pytwarning�s

cOsT|j|ddd|j�|j|�d|d<|j||j|||�dS(s� Information log using info level [1..info_max].
        There are additional infox functions according to info_max from
        __init__RliRmiRN(RoRRR}R~RQ(RR
RHR@RA((s8/usr/lib/python2.7/site-packages/firewall/core/logger.pyR>�s

cOsM|j|ddd|j�|j|�d|d<|j||||�dS(s� Debug log using debug level [1..debug_max].
        There are additional debugx functions according to debug_max
        from __init__RliRmRN(RoRTR}R~(RR
RHR@RA((s8/usr/lib/python2.7/site-packages/firewall/core/logger.pyRD�s

cCs)|j|jtj�dgdi�dS(NR@RA(R~RVt	tracebackt
format_exc(R((s8/usr/lib/python2.7/site-packages/firewall/core/logger.pyt	exception�scCs8||ks||kr4td|||f��ndS(Ns*Level %d out of range, should be [%d..%d].(RP(RR
RlRm((s8/usr/lib/python2.7/site-packages/firewall/core/logger.pyRo�scCsD|s
dSx3|j�D]%}|dkrtd|��qqWdS(NtnlRstnofmts0Key '%s' is not allowed as argument for logging.(snlsfmtsnofmt(tkeysRP(RRAtkey((s8/usr/lib/python2.7/site-packages/firewall/core/logger.pyR}�s
cCs*|s|dkr&td|��ndS(NR=sDomain '%s' is not valid.(RP(RRg((s8/usr/lib/python2.7/site-packages/firewall/core/logger.pyRe�scCs�||jkr�t|t�s-t|t�r6|}n	|g}x�|D]J}|rq|j|ddd|j�qF|j|d|jd|j�qFWnY|r�gt|j	|j�D]}|^q�}n(gt|j|j�D]}|^q�}|S(s Generate log level array. RliRm(
tALLt
isinstancetlistttupleRoRTR(RRRWtDEBUG1(RR
RRqRb((s8/usr/lib/python2.7/site-packages/firewall/core/logger.pyRn�s		

+(cCspt|t�st|t�r'|}n	|g}x9|D]1}t|jt�s7td|jj��q7q7W|S(s Generate target array. s '%s' is no valid logging target.(R�R�R�t
issubclasst	__class__RRPR(RRdttargetst_target((s8/usr/lib/python2.7/site-packages/firewall/core/logger.pyt_getTargets�s		
cCs�|r.|j}|j}d|jdf}n(|j}|j}|j|jdf}t|�dkru|j�nxwt	|d|d�D]^}||kr�q�nxC||D]7\}}}||kr�|j
|g�j|�q�q�Wq�WdS(s% Generate dict with domain by level. iiN(RORMRTRNRLR(RRR+tclearRWt
setdefaulttappend(RRRNRLt_rangeR
RgRc((s8/usr/lib/python2.7/site-packages/firewall/core/logger.pyt_genDomainss				
c	Cs�|j|�|j||�}|j|�}|r@|j}n	|j}x5|D]-}x$|D]}|||fg||<q]WqPW|j|�dS(N(ReRnR�RMRLR�(	RRgRdR
RsRRqR�RL((s8/usr/lib/python2.7/site-packages/firewall/core/logger.pyRrs
	

c	Cs�|j|�|j||�}|j|�}|r@|j}n	|j}xA|D]9}x0|D](}|j|g�j|||f�q]WqPW|j|�dS(N(ReRnR�RMRLR�R�R�(	RRgRdR
RsRRqR�RL((s8/usr/lib/python2.7/site-packages/firewall/core/logger.pyRt-s
	

*c
Cs|j|�|j||�}|j|�}|r@|j}n	|j}x�|D]�}	x�|D]�}|	|kruq]n|||f||	kr�||	j|||f�t||	�dkr�||	=q]q�n||jkr]td|	||j	j
|f��q]q]WqPW|j|�dS(NisDNo mathing logging for level %d, domain %s, target %s and format %s.(ReRnR�RMRLtremoveR+R�RPR�RR�(
RRgRdR
RsRRqR�RLRF((s8/usr/lib/python2.7/site-packages/firewall/core/logger.pyRw<s&
	

	'cCs�|j||�}|stS|dd}|r<|j}n	|j}xP||D]D\}}}|dks�|j|�s�tj|d|�rPtSqPWtS(NRgt.RE(t_genDicttFalseRMRLR4tfnmatchtfnmatchcasetTrue(RR
Rt_dicttpoint_domainRLRgRc((s8/usr/lib/python2.7/site-packages/firewall/core/logger.pyRzUs	c	CsT|jjdkrf|jjd}||jkrf|j|}|j|j|j�}|rc|Sqfntj|j�}|j}|j|j	kr�t
|j	|jd�r�|j	|jj|kr�dSnx�|j	j
�D]p\}}t|tj�r�t
||j�rLt||j�}t|tj�rI|j|krF|SqIqLq�q�WdS(s7 Function to get calling class. Returns class or None. it	func_codeN(tf_codetco_argcounttco_varnamestf_localst
_getClass2R�tinspectt	getmoduletco_namet__dict__thasattrt__code__RtitemsR�ttypest	ClassTypetgetattrtFunctionType(	Rtframetselfnamet_selftobjtmoduletcodeRctvalue((s8/usr/lib/python2.7/site-packages/firewall/core/logger.pyt	_getClassis*

	cCsvx?|jj�D].}t|tj�r|j|kr>|SqqWx-|jD]"}|j||�}|rL|SqLWdS(s@ Internal function to get calling class. Returns class or None. N(	R�tvaluesR�R�R�R�t	__bases__R�R(RR�R�R�tbaset_obj((s8/usr/lib/python2.7/site-packages/firewall/core/logger.pyR��scOs�d}d|kr|d}nd}d|kr>|d}nd}d|kr]|d}n|j||�}|sydSt|�dkr�|||d<n1t|�dkr�||d|d<n
||d<|dd}	|r�|j}
n	|j}
g}x�|
|D]�\}}
}|
|kr(qn|d	ks]|	j|d�s]tj|d|�r|so|j}nd
|kr�|d
}n|r�|
j|d|||�n|
j|||||�|r�|
jd|||�n|j	|
�qqWdS(NiRiR�R�R?RgR�RERss
(
R�R+RMRLR4R�R�RHR
R�(RR
RHR@RARR�R�R�R�RLtused_targetsRgRd((s8/usr/lib/python2.7/site-packages/firewall/core/logger.pyR~�sL



	
cCs6g}t}|r0|j}|j}|j}n|j}|j}|j}xr|D]j}|dkr�|||kr�t}t|�dkr�g}nPq�qR|||krR|j	|�qRqRW|r�t|�dkr�dS||kr�dStj�}	x2|	r-|	j
r-|	jd|jkr-|	j
}	q�W|	sCtd��n|	jd}
|
d}x'|D]}|j|�rag}PqaqaW|	j}t|
�}
x�||D]�}|jd�}|dkr�q�n|dkr�|| }n|}|
t|�kr|
j|�s%dSq�|j|
�s�dSq�Wd}||krH||}ni	|jd6|	jd	6|
d
6dd6|jd6dd
6|d6|d6tj|jtj��d6}|ddkr�d|d<nt}x+||D]}|dkr�q�nt}Pq�W|jjd�dksD|jjd�dksD|sDt|�dkrl|j|	�}|rl|j|d<qlnd|d
|d
<|ddkr�|d
cd|d7<n|ddkr�|d
cd|d7<nt|�dkr�|S|d
d}x7|D]/}|j|�s*tj|d
|�r�|Sq�WdS(s Internal function. REiiRs Frame information not available.R�R=tfiletlineR�tclasstfunctionRgRpR
tdatet?s	%(domain)s%(class)N( R�RGRORKRFRNRJR�R+R�RR�tcurrentframetf_backt	f_globalsRRPR4R�tfindtco_filenametf_linenoR�ttimetstrftimeRIt	localtimeRHR�RR�R�(RR
Rt
check_domainstsimple_matchR�RNRJRgtftmodule_nametpoint_moduletcot_lenRbtdt	level_strt
domain_neededR�R�((s8/usr/lib/python2.7/site-packages/firewall/core/logger.pyR��s�					
	(



	






N(8RRRR�RfR(RVR&R$RRRRRRRRRhRZRiR[RjR\RkR]RURYRR^R_RuRvRxRyR{R|RR�R�R>RDR�RoR}ReRnR�R�RrRtRwRzR�R�R~R�(((s8/usr/lib/python2.7/site-packages/firewall/core/logger.pyR�sdG			;																										 		4(t__all__RR�R�R�R�RR�R9tos.pathRtobjectRRRRRRR(((s8/usr/lib/python2.7/site-packages/firewall/core/logger.pyt<module>s(-(���	4

ZeroDay Forums Mini