
    ߀Ej|                    ^    S SK Jr  S SKrS SKrS SKrS SKrS SKJr  \" S5      r1 Skr	SS jr
g)    )annotationsN)
get_loggerzactions.logs>   phpsystemnginx_errornginx_accessc           	         U R                  S5      nU(       a
  U[        ;  a  SSU 3S.$ U R                  SS5      nU(       a@  [        R                  " SSU5      nU(       a  [        R                  " SU5      (       d  SS	S.$ U R                  S
S5      n [        U5      nUS:  a  SnOUS:  a  SnSnSnUS:X  a  U(       a  SU S3nOrSnOoUS:X  a  U(       a  SU S3nO[SnOXUS:X  a=  [        R                  " S5      [        R                  " S5      -   nU(       a  US   nOSnOUS:X  a  SS[        U5      S/n/ nU(       ar   [        R                  " USSS SSS!9n	U	R                  S:X  a  U	R                  R                  5       nGO[        R!                  S"U	R                  U	R"                  5        OU(       a  [(        R*                  R-                  U5      (       a  [(        R*                  R/                  U5      (       a~   [        R                  " S$S[        U5      U/SSS SSS!9n	U	R                  S:X  a  U	R                  R                  5       nOD[        R!                  S%U	R                  U	R"                  5        O[        R1                  S'U5        / nSUUU=(       d    S(S).$ ! [        [        4 a    Sn GN f = f! [$         a   n
[        R'                  S#U
5         Sn
A
NNSn
A
ff = f! [$         a   n
[        R'                  S&XZ5         Sn
A
N{Sn
A
ff = f! [$         a.  n[        R'                  S*U5        S[        U5      S.s SnA$ SnAff = f)+z*Read the last N lines of log files safely.log_typeFzInvalid log type: )successerrordomain z[^a-zA-Z0-9.-]z^[a-zA-Z0-9.-]+$zInvalid domain name formatlines      i  Nr   z/var/log/nginx/z.access.logz/var/log/nginx/access.logr   z
.error.logz/var/log/nginx/error.logr   z/var/log/php*-fpm.logz/var/log/php*.logr   z/var/log/php-fpm.logr   
journalctlz-nz
--no-pagerTignore)capture_outputtexterrorsshellcheckz*System log command failed with code %d: %sz$Failed to run system log command: %stailz$Tail command failed with code %d: %szFailed to tail log file %s: %szLog file does not exist: %sjournald)r   r   r
   pathzLog read exception: %s)getALLOWED_LOG_TYPESresubmatchint
ValueError	TypeErrorglobstr
subprocessrun
returncodestdout
splitlineslogwarningstderr	Exceptionr   osr   existsisfileinfo)payloadr
   r   	lines_rawr   r   cmd	php_files	ret_linesreseexcs               6D:\Programs\laragon\www\wolf\agent\src\actions\logs.pyhandle_log_readr<      s*   l
;;z*8+<< -hZ8 
 Xr*VV-r6:F*=v!F!F$9 
 KK-			NE
 19ET\E ~%(<2&(
;1		"9:TYYGZ=[[I |-!s5z<@C  "	E nn#'# >>Q& #

 5 5 7IKK Lcnn^a^h^hi ww~~d##t(<(<I$..s5z48'+!'##C ~~*$'JJ$9$9$;	$JCNN\_\f\fg
 6=	  &J	
 	
U I& 	E	b  E		@!DDE$ ! III>HHI  
		*C0X
 	

s   )L! AL! L! J. #B$L! AK L! +K 8AL! 	AK4 L! +K4 (L! .K L! KL! 
K1K,'L! ,K11L! 4
L>LL! LL! !
M+#MMM)r3   dictreturnr=   )
__future__r   r$   r/   r   r&   loggerr   r+   r   r<        r;   <module>rC      s-    "  	 	   D n
rB   