Qfv ddlZddlZddlZddlZddlZddlZddlZddlZddlm Z m Z m Z ddl Z ddl Z ddlZdZdZdZdZdZdZdZGd d ej,ZGd d eZGd deZGddej,ZGddej6ZGddeZGddej6ZGddej6ZGddej6Z Gddej6Z!Gddej6Z"Gdd e"Z#Gd!d"ej6Z$Gd#d$e%Z&y)%N)ST_DEVST_INOST_MTIMEi<#i=#i>#i?#iQc0eZdZ dZdZddZdZdZdZy)BaseRotatingHandlerNcz tjj||||||||_||_||_y)Nmodeencodingdelayerrors)logging FileHandler__init__r r rselffilenamer r r rs 7/opt/alt/python312/lib64/python3.12/logging/handlers.pyrzBaseRotatingHandler.__init__6sG  $$T8$.6e,2 % 4    c |j|r|jtjj ||y#t $r|j |YywxYwN)shouldRollover doRolloverrremit Exception handleErrorrrecords rrzBaseRotatingHandler.emitAsW  %""6*!    $ $T6 2 %   V $ %sAAA"!A"c\ t|js|}|S|j|}|Sr)callablenamer)r default_nameresults rrotation_filenamez%BaseRotatingHandler.rotation_filenameOs6  #!F ZZ -F rc t|js7tjj |rtj ||yy|j||yr)r!rotatorospathexistsrename)rsourcedests rrotatezBaseRotatingHandler.rotatebsH  %ww~~f% &$'& LL &r)NFN) __name__ __module__ __qualname__r"r'rrr%r.rrrr-s' EG  %&'rrc&eZdZ ddZdZdZy)RotatingFileHandlerNc |dkDrd}d|vrtj|}tj||||||||_||_y)Nrabr r r)io text_encodingrrmaxBytes backupCount)rrr r;r<r r rs rrzRotatingFileHandler.__init__|s\ 2 a<D d?''1H$$T8TH+0 % A  &rc8 |jr!|jjd|_|jdkDr:t|jdz ddD]}|j d|j |fz}|j d|j |dzfz}t jj|sft jj|rt j|t j|||j |j dz}t jj|rt j||j|j ||js|j|_yy)Nrz%s.%dz.1)streamcloser<ranger% baseFilenamer(r)r*remover+r.r _open)risfndfns rrzRotatingFileHandler.doRollovers=  ;; KK   DK   a 4++a/B7,,W8I8I17M-MN,,W8I8I89A8?.?@77>>#&ww~~c* #IIc3'8(():):T)ABCww~~c" # KK))3 /zz**,DKrc |j|j|_|jdkDr|jj}|syd|j |z}|t |z|jk\rTt jj|jr*t jj|jsyyy)NrFz%s T) r@rEr;tellformatlenr(r)r*rCisfile)rrposmsgs rrz"RotatingFileHandler.shouldRollovers ;; **,DK ==1 ++""$C4;;v..CSX~.77>>$"3"34RWW^^DL]L]=^ r)r6rrNFN)r/r0r1rrrr2rrr4r4ws!DE48"'H'.rr4c4eZdZ ddZdZdZdZdZy)TimedRotatingFileHandlerNc tj|}tj||d||| |j |_||_||_||_|j dk(rd|_ d|_ d} n=|j dk(rd|_ d |_ d } n|j d k(rd |_ d |_ d} n|j dk(s|j dk(rd|_ d|_ d} n|j jdrd|_ t|j dk7rtd|j z|j ddks|j ddkDrtd|j zt|j d|_d|_ d} ntd|j zt!j"| t j$|_|j|z|_ |j(}t*j,j/|rt+j0|t2} ntt5j4} |j7| |_y)Nr6r8Sr>z%Y-%m-%d_%H-%M-%Sz0(?H YY# j!8(DM$DK8H YY ! !# &,DM499~" !knrnwnw!wxxyy|c!TYYq\C%7 !PSWS\S\!\]] 1.DN$DK8HFRS S 8RXX6  0 $$ 77>>( #!(+ADIIK A..q1rc  ||jz}|jdk(s|jjdr|jrt j |}nt j |}|d}|d}|d}|d}|jt}nJ|jjdz|jjzdz|jjz}||dz|zdz|zz } | dkr| tz } |d zd z}|| z}|jjdrk|} | |jk7r@| |jkr|j| z } nd| z |jzd z} || tzz }||jtd zz z }n||jtz z }|jsK|d } t j |d } | | k7r)| s d }t j |d z d sd}nd }||z }|S)NrYrZrUrr>r?rW) rbr_rdr`rmgmtime localtimera _MIDNIGHThourminutesecondrg)r currentTimer$rp currentHour currentMinute currentSecond currentDay rotate_tsrday daysToWaitdstNow dstAtRolloveraddends rrnz(TimedRotatingFileHandler.computeRollovers t}}, 99 "dii&:&:3&?xxKK ,NN;/A$KaDMaDM1J{{"% "kk..3dkk6H6HH"LKK&&' kB.>"DAAvY(1n1  1_F yy##C( $..(T^^+%)^^c%9 %&Wt~~%=%A j944F$--)a-77$--)33882 $v 6r : ]*!!&#~~fTk:2>%&F!%f$F rc2 ttj}||jk\rjtjj |j r@tjj|j s|j||_yyy)NFT) rfrmror(r)r*rCrMrn)rrrps rrz'TimedRotatingFileHandler.shouldRolloveresm    ww~~d//0HYHY9Z#'"6"6q"9rc tjj|j\}}tj|}g}|j q|dz}t |}|D][}|d||k(s ||d}|jj|s-|jtjj||]n|D]}|jj|} | s!|j |jdz| dz} tjj| |k(r0|jtjj|||jj|| jdz} | rt ||jkrg}|S|j|dt ||jz }|S)N.rr>)r(r)splitrClistdirr"rLrk fullmatchappendjoinsearchbasenamestartr<sort) rdirNamebaseName fileNamesr$prefixplenfileNamercmrHs rgetFilesToDeletez)TimedRotatingFileHandler.getFilesToDeletexs GGMM$*;*;<JJw'  :: ^Fv;D%ET?f,%de_F}}..v6 bggll7H&EF & & MM((2**T%6%6%>#   ;; KK   DK D%%s+   a **, ! -zz**,DK..{;r)hr>rNFFNN)r/r0r1rrnrrrr2rrrQrQs2DE?CA2FKZ&$L&@g@) rHandlerrhostportaddresssock closeOnError retryTime retryStartretryMax retryFactorrrrs rrzSocketHandler.__init__sn    &  <DL $>63E3EFF   g & t||,    s 5BB-c tj}|jd}n||jk\}|r |j|_d|_yy#t$r}|j|j |_nH|j |jz|_|j |jkDr|j|_||j z|_YywxYwNT) rmrrrrr retryPeriodrr)rnowattempts r createSocketzSocketHandler.createSocketGs iik >> !Gdnn,G  8 OO- !%  8>>)'+D$'+'7'7$:J:J'JD$''$--7+/==(!$t'7'7!7 8sABCCc |j|j|jr |jj|yy#t$r$|jj d|_YywxYwr)rrsendallrrArrs rsendzSocketHandler.sendcsj 99      99 ! !!!$  ! !   !sA*A54A5c> |j}|r|j|}t|j}|j |d<d|d<d|d<|j ddt j|d}tjdt|}||zS)NrOargsexc_infomessager>z>L) rrKdict__dict__ getMessagepoppickledumpsstructpackrL)rreidummydrslens r makePicklezSocketHandler.makePicklevs __ KK'E  !$$&%& *  i LLA {{4Q(axrc |jr.|jr"|jjd|_ytjj ||yr)rrrArrrrs rrzSocketHandler.handleErrorsA     IIOO DI OO ' 'f 5rc |j|}|j|y#t$r|j|YywxYwr)rrrr)rrrs rrzSocketHandler.emitsB  %'A IIaL %   V $ %s"&AAc |j |j}|rd|_|jtjj||j y#|j wxYwr)acquirerrArrreleaserrs rrAzSocketHandler.closesX   99D   OO ! !$ ' LLNDLLN AA((A:N)r>) r/r0r1rrrrrrrrAr2rrrrs/ 2"88!&, 6 % rrc eZdZ dZdZdZy)DatagramHandlercB tj|||d|_y)NF)rrrrs rrzDatagramHandler.__init__s#  tT40!rc |jtj}ntj}tj|tj}|Sr)rrrAF_INET SOCK_DGRAM)rfamilyrs rrzDatagramHandler.makeSockets@  99 ^^F^^F MM&&"3"3 4rc |j|j|jj||jyr)rrsendtorrs rrzDatagramHandler.sends7  99      DLL)rN)r/r0r1rrrr2rrrrs "  *rrc xeZdZ dZdZdZdZdZdZdZ dZ dZ dZ dZ dZdZdZdZdZd Zd Zd Zd Zd ZdZdZdZdZdZdZdZdZdZ dZ!dZ"eeee eeee eeeed Z#idedededededed e d!ed"e d#ed$ed%ed&ed'ed(e d)ed*eeeeee e!e"d+Z$d,d-d.d/d0d1Z%d2e&fe d3fd4Z'd5Z(d6Z)d7Z*d8Z+d9Z,d:Z-d;Z.d<Z/y3)= SysLogHandlerrr>r[rrrsrtrurv ) alertcritcriticaldebugemergerrerrorinfonoticepanicwarnwarningauthauthprivconsolecrondaemonftpkernlprmailnewsntpsecurityz solaris-cronsysloguseruucplocal0)local1local2local3local4local5local6local7r rrrr )DEBUGINFOWARNINGERRORCRITICAL localhostNc tjj|||_||_||_d|_|jyr)rrrrfacilitysocktyperr)rrr4r5s rrzSysLogHandler.__init__MsC    &       rcL|j}|tj}tjtj||_ |jj |||_y#t $r|jj |jtj}tjtj||_ |jj |||_Yy#t $r|jj wxYwwxYwr)r5rrrrrrAr)rr use_socktypes r_connect_unixsocketz!SysLogHandler._connect_unixsocketbs}}  !,,LmmFNNLA   KK   ((DM  KK   }}(!--L -- EDK  ##G, ,   !!#  s "A,,A)D#"C::%DD#cF |j}|j}t|trd|_ |j |yd|_|tj}|\}}tj||d|}|s t d|D]K}|\}}}} } dx} } tj|||} |tjk(r| j| n |  |_||_y#t $rYywxYw#t $r} | } | | jYd} ~ d} ~ wwxYw)NTFrz!getaddrinfo returns an empty list) rr5 isinstancestr unixsocketr8rrr getaddrinforrrA)rrr5rrressresafproto_sarrexcs rrzSysLogHandler.createSocketzs3 ,,== gs #"DO  ((1$DO!,, JD$%%dD!X>DABB-0*HeQ!!d%!==Xu=D6#5#55 R( DK$DM3  $%C' %s)C*;C9* C65C69 D DD c t|tr|j|}t|tr|j|}|dz|zS)Nrr)r:r;facility_namespriority_names)rr4prioritys rencodePriorityzSysLogHandler.encodePrioritysL h $**84H h $**84HA ))rc |j |j}|rd|_|jtjj||j y#|j wxYwr)rrrArrrrs rrAzSysLogHandler.closesX   ;;D"  OO ! !$ ' LLNDLLNrc< |jj|dS)Nr) priority_mapget)r levelNames r mapPriorityzSysLogHandler.mapPrioritys"   $$Y ::rTc |j|}|jr|j|z}|jr|dz }d|j|j|j |j z}|jd}|jd}||z}|js|j|jr |jj|y|j tj"k(r'|jj%||jy|jj'|y#t$rS|jj|j|j|jj|YywxYw#t($r|j+|YywxYw)Nz<%d>utf-8)rKident append_nulrIr4rO levelnameencoderrr<rrrAr8rr5rrrrr)rrrOprios rrzSysLogHandler.emitsk  %++f%Czzjj3&v D// 040@0@AQAQ0RTTD;;w'D**W%C*C;;!!#*KK$$S) &"3"33 ""3 5 ##C(*KK%%',,T\\:KK$$S)* %   V $ %s>CF#E$AF#(F#AF F#F  F##G?G)0r/r0r1 LOG_EMERG LOG_ALERTLOG_CRITLOG_ERR LOG_WARNING LOG_NOTICELOG_INFO LOG_DEBUGLOG_KERNLOG_USERLOG_MAIL LOG_DAEMONLOG_AUTH LOG_SYSLOGLOG_LPRLOG_NEWSLOG_UUCPLOG_CRON LOG_AUTHPRIVLOG_FTPLOG_NTP LOG_SECURITY LOG_CONSOLE LOG_SOLCRON LOG_LOCAL0 LOG_LOCAL1 LOG_LOCAL2 LOG_LOCAL3 LOG_LOCAL4 LOG_LOCAL5 LOG_LOCAL6 LOG_LOCAL7rGrFrLSYSLOG_UDP_PORTrr8rrIrArOrTrUrr2rrrrs$IIHGKJHIHHHJHJGHHHLGGLKKJJJJJJJJ  N                                   ! "  # $#""""""1 N< L!,_="T*0,%\ * ; EJ&%rrc$eZdZ ddZdZdZy) SMTPHandlerNct tjj|t|tt fr|\|_|_n|dc|_|_t|tt fr|\|_|_ nd|_||_ t|tr|g}||_ ||_ ||_||_yr)rrrr:listtuplemailhostmailportusernamepasswordfromaddrr;toaddrssubjectsecurer)rrrrr credentialsrrs rrzSMTPHandler.__init__s   & hu .+3 (DM4=+3T (DM4= kD%= 1+6 (DM4= DM  gs #iG    rc |jSr)rrs r getSubjectzSMTPHandler.getSubjects ||rc" ddl}ddlm}ddl}|j}|s |j }|j |j||j}|}|j|d<dj|j|d<|j||d<|jj|d<|j|j!||j"rk|j$9|j'|j(|j$|j'|j+|j"|j,|j/||j1y#t2$r|j5|YywxYw) Nr) EmailMessagerFrom,ToSubjectDate)smtplib email.messager email.utilsr SMTP_PORTSMTPrrrrrrutilsry set_contentrKrrehlostarttlsloginr send_messagequitrr)rrrremailrsmtprOs rrzSMTPHandler.emit(s.  %  2 ==D((<< tT\\<JD.C--CK.CI!__V4C N++//1CK OODKK/ 0}};;*IIK!DMM4;;/IIK 4==$--8   c " IIK %   V $ %sE-E11F F)NNg@)r/r0r1rrrr2rrr{r{s9<!F%rr{c4eZdZ ddZdZdZdZdZdZy) NTEventLogHandlerNc tjj| ddl}ddl}||_||_|sxtjj|j j}tjj|d}tjj|dd}||_ ||_ |j j||||j"|_tj&|j(tj*|j(tj,|j.tj0|j"tj2|j"i|_y#t$r}t!|dddk7rYd}~d}~wwxYw#t6$rt9dd|_YywxYw)Nrzwin32service.pydwinerrorrtzWThe Python Win32 extensions for NT (service, event logging) appear not to be available.)rrrwin32evtlogutil win32evtlogappname_welur(r)r__file__rdllnamelogtypeAddSourceToRegistryrgetattrEVENTLOG_ERROR_TYPEdeftyper-EVENTLOG_INFORMATION_TYPEr.r/EVENTLOG_WARNING_TYPEr0r1typemap ImportErrorprint)rrrrrres rrzNTEventLogHandler.__init__RsX  &  /"DL(DJ''-- (;(;<''-- 3'',,wqz3FG"DL"DL  ..wI '::DL +"G"G +"G"G+"C"C +"A"A  +"A"A  DL  1j$/145   ? @DJ s=BFE8BF8 FFFFFF=<F=c y)Nr>r2rs r getMessageIDzNTEventLogHandler.getMessageIDus  rc y)Nrr2rs rgetEventCategoryz"NTEventLogHandler.getEventCategorys  rcd |jj|j|jSr)rrMlevelnorrs r getEventTypezNTEventLogHandler.getEventTypes( || ==rc> |jrp |j|}|j|}|j|}|j |}|jj |j ||||gyy#t$r|j|YywxYwr) rrrrrK ReportEventrrr)rridcattyperOs rrzNTEventLogHandler.emits :: )&&v.++F3((0kk&) &&t||RdSEJ  )  ( )sA.A??BBcD tjj|yr)rrrArs rrAzNTEventLogHandler.closes  d#r)N Application) r/r0r1rrrrrrAr2rrrrHs&!F >)" $rrc,eZdZ ddZdZdZdZy) HTTPHandlerNc tjj||j}|dvr t d|s | t d||_||_||_||_||_ ||_ y)N)GETPOSTzmethod must be GET or POSTz3context parameter only makes sense with secure=True) rrrr^rerurlmethodrrcontext)rrrrrrrs rrzHTTPHandler.__init__s    &  (9: :'-01 1   & rc |jSr)rrs r mapLogRecordzHTTPHandler.mapLogRecords rc ddl}|r)|jj||j}|S|jj |}|S)Nr)r) http.clientclientHTTPSConnectionrHTTPConnection)rrrhttp connections r getConnectionzHTTPHandler.getConnectionsP  44T4<<4PJ33D9Jrc ddl}|j}|j||j}|j}|j j |j|}|jdk(r#|jddk\rd}nd}|d||fzz}|j|j||jd}|dk\r|d|}|jdk(r6|jdd |jd tt||jreddl} d |jzj!d } d | j#| j%j'dz} |jd| |j)|jdk(r |j+|j!d |j-y#t.$r|j1|YywxYw)Nrr?&z%c%s:rz Content-typez!application/x-www-form-urlencodedzContent-lengthz%s:%srSzBasic ascii Authorization) urllib.parserrrrparse urlencoderrfind putrequest putheaderr;rLrbase64rW b64encodestripdecode endheadersr getresponserr) rrurllibrrrdataseprFrrs rrzHTTPHandler.emits # % 99D""45A((C<<))$*;*;F*CDD{{e#HHSMQ&CCFc4[00 LLc * #AAvBQx{{f$ N?A ,c#d)n=t///77@v//288:AA'JJ OQ/ LLN{{f$t{{7+, MMO %   V $ %sGGG10G1)rFNN)r/r0r1rrrrr2rrrrs%KO( )%rrc,eZdZ dZdZdZdZdZy)BufferingHandlerc` tjj|||_g|_yr)rrrcapacitybuffer)rrs rrzBufferingHandler.__init__s)    &   rcH t|j|jk\Sr)rLrrrs r shouldFlushzBufferingHandler.shouldFlushs! DKK DMM12rc |jj||j|r|jyyr)rrrrrs rrzBufferingHandler.emit$s7 6"   F # JJL $rc |j |jj|jy#|jwxYwr)rrclearrrs rrzBufferingHandler.flush/s:   KK    LLNDLLNs >Ac |jtjj|y#tjj|wxYwr)rrrrArs rrAzBufferingHandler.close;s:  ( JJL OO ! !$ 'GOO ! !$ 's 3!AN)r/r0r1rrrrrAr2rrrr s  3   (rrcHeZdZ ejddfdZdZdZdZdZ y) MemoryHandlerNTc\ tj||||_||_||_yr)rr flushLeveltarget flushOnClose)rrrrrs rrzMemoryHandler.__init__Ls/  !!$1$ (rc~ t|j|jk\xs|j|jk\Sr)rLrrrrrs rrzMemoryHandler.shouldFlush`s8 DKK DMM144??2 4rc |j ||_|jy#|jwxYwr)rrr)rrs r setTargetzMemoryHandler.setTargetgs1    DK LLNDLLNs+=c |j |jrF|jD]}|jj||jj |j y#|j wxYwr)rrrhandlerrrs rrzMemoryHandler.flushqsa   {{"kkFKK&&v.* !!# LLNDLLNs AA66Bc |jr|j|j d|_tj ||j y#|j wxYw#|j d|_tj ||j w#|j wxYwxYwr)rrrrrrArrs rrAzMemoryHandler.closes     LLN "  &&t,   LLN "  &&t,  s.A2AA/2CB1 C1CC) r/r0r1rr0rrrrrAr2rrrrFs. -4MM$")(4"rrc&eZdZ dZdZdZdZy) QueueHandlerc` tjj|||_d|_yr)rrrqueuelistener)rrs rrzQueueHandler.__init__s)    &  rc< |jj|yr)r put_nowaitrs renqueuezQueueHandler.enqueues  f%rc |j|}tj|}||_||_d|_d|_d|_d|_|Sr)rKcopyrrOrrexc_text stack_info)rrrOs rpreparezQueueHandler.preparesU *kk&!6"    rc |j|j|y#t$r|j|YywxYwr)rr rrrs rrzQueueHandler.emits>  % LLf- . %   V $ %s $AAN)r/r0r1rrr rr2rrrrs&B %rrcHeZdZ dZdddZdZdZdZdZd Z d Z d Z y) QueueListenerNF)respect_handler_levelc> ||_||_d|_||_yr)rhandlers_threadr)rrrrs rrzQueueListener.__init__s&     %:"rc: |jj|Sr)rrM)rblocks rdequeuezQueueListener.dequeues zz~~e$$rc tj|jx|_}d|_|j y)N)rT) threadingThread_monitorrrr)rrps rrzQueueListener.starts4 %++4==AA q  rc |Srr2rs rr zQueueListener.prepares  rc |j|}|jD]>}|jsd}n|j|jk\}|s.|j |@yr)r rrrlevelr)rrhandlerprocesss rrzQueueListener.handle sT f%}}G-- ..GMM9v& %rc |j}t|d} |jd}||jur|r|j y|j ||r|j W#tj $rYywxYw)N task_doneT)rhasattrr _sentinelr"rEmpty)rq has_task_doners rrzQueueListener._monitors  JJ;/  d+T^^+$  F# KKM;;  s1A2#A22BBcP |jj|jyr)rrr$rs renqueue_sentinelzQueueListener.enqueue_sentinel4s  dnn-rch |j|jjd|_yr)r)rrrs rstopzQueueListener.stop>s,    r) r/r0r1r$rrrr rrr)r+r2rrrrs9 I?D;% ' .. rr)'r9rrr(rrrmrhrlrrrrrr DEFAULT_TCP_LOGGING_PORTDEFAULT_UDP_LOGGING_PORTDEFAULT_HTTP_LOGGING_PORTDEFAULT_SOAP_LOGGING_PORTrySYSLOG_TCP_PORTrzrrr4rQrrrrrr{rrrrrobjectrr2rrr2sH"9888))  #"""!!  H''--H'TT-Tlw<2w