+
    =l j™  ã                   ó(  € ^ RI t ^ RIt^ RIt^ RIt^ RIHt ^ RIHtHtH	t	H
t
 ^ RIHtHtHtHt ^ RIHt  ! R R]P$                  4      t ! R R	]P$                  4      t ! R
 R]P*                  4      tR R ltR R ltR R ltR tR R ltR tR# )é    N)ÚOrderedDict)ÚAnyÚDictÚListÚUnion)ÚdefaultsÚsecret_managerÚsystemÚutil)ÚUAConfigc                   ó6   a € ] tR t^t o RtV 3R lR ltRtV tR# )ÚRegexRedactionFilterú,A logging filter to redact confidential infoc                ó4   <€ V ^8„  d   QhRS[ P                  /# ©é   Úrecord©ÚloggingÚ	LogRecord)ÚformatÚ__classdict__s   "€Ú./usr/lib/python3/dist-packages/uaclient/log.pyÚ__annotate__Ú!RegexRedactionFilter.__annotate__   ó   ø€ ÷ ñ ™W×.Ñ.ñ ó    c                ób   € \         P                  ! \        VP                  4      4      Vn        R # ©T)r   Úredact_sensitive_logsÚstrÚmsg©Úselfr   s   &&r   ÚfilterÚRegexRedactionFilter.filter   s   € Ü×/Ò/´°F·J±J³Ó@ˆŒ
Ùr   © N©Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r%   Ú__static_attributes__Ú__classdictcell__©r   s   @r   r   r      ó   ø‡ € Ù6÷ö r   r   c                   ó6   a € ] tR t^t o RtV 3R lR ltRtV tR# )ÚKnownSecretRedactionFilterr   c                ó4   <€ V ^8„  d   QhRS[ P                  /# r   r   )r   r   s   "€r   r   Ú'KnownSecretRedactionFilter.__annotate__   r   r   c                ót   € \         P                  P                  \        VP                  4      4      Vn        R # r   )r	   ÚsecretsÚredact_secretsr!   r"   r#   s   &&r   r%   Ú!KnownSecretRedactionFilter.filter   s%   € Ü#×+Ñ+×:Ñ:¼3¸v¿z¹z»?ÓKˆŒ
Ùr   r'   Nr(   r0   s   @r   r3   r3      r1   r   r3   c                   óB   a € ] tR t^t o RtRtRtRtV 3R lR ltRt	V t
R# )	ÚJsonArrayFormatterzQJson Array Formatter for our logging mechanism
Custom made for Pro logging needs
z%Y-%m-%dT%H:%M:%Sz%s.%03dc                ó:   <€ V ^8„  d   QhRS[ P                  RS[/# )r   r   Úreturn)r   r   r!   )r   r   s   "€r   r   ÚJsonArrayFormatter.__annotate__,   s!   ø€ ÷ ;ñ ;™W×.Ñ.ð ;±3ñ ;r   c                óú  € VP                  4       Vn        V P                  V4      Vn        / pVP                  '       d   V P                  VP                  4      VR &   VP                  R 4      '       g"   VP                  '       d   VP                  VR &   VP                  '       d   V P                  VP                  4      VR&   VP                  P                  R4      pV'       d(   \        V\        4      '       d   VP                  V4       \        4       pV P                   F"  pVP                  P                  V4      pWdV&   K$  	  W$R&   \         P"                  ! \%        VP'                  4       4      4      # )Úexc_infoÚ
stack_infoÚextra)Ú
getMessageÚmessageÚ
formatTimeÚasctimer@   ÚformatExceptionÚgetÚexc_textrA   ÚformatStackÚ__dict__Ú
isinstanceÚdictÚupdater   Úrequired_fieldsÚjsonÚdumpsÚlistÚvalues)r$   r   Úextra_message_dictrB   Úlocal_log_recordÚfieldÚvalues   &&     r   r   ÚJsonArrayFormatter.format,   s4  € Ø×*Ñ*Ó,ˆŒØŸ™¨Ó0ˆŒàÐØ�?�?ˆ?Ø-1×-AÑ-AØ—‘ó.Ð˜zÑ*ð "×%Ñ% j×1Ò1°f·o·o°oØ-3¯_©_Ð˜zÑ*Ø××ÐØ/3×/?Ñ/?Ø×!Ñ!ó0Ð˜|Ñ,ð —‘×#Ñ# GÓ,ˆß”Z ¤t×,Ò,Ø×%Ñ% eÔ,ô '›=Ðà×)Ô)ˆEØ—O‘O×'Ñ'¨Ó.ˆEØ&+˜UÓ#ñ *ð %7˜Ñ!Ü�zŠzœ$Ð/×6Ñ6Ó8Ó9Ó:Ð:r   r'   N)rF   Ú	levelnameÚnameÚfuncNameÚlinenorD   )r)   r*   r+   r,   r-   Údefault_time_formatÚdefault_msec_formatrO   r   r.   r/   r0   s   @r   r;   r;      s)   ø‡ € ñð .ÐØ#Ðð€O÷;ö ;r   r;   c                ó$   € V ^8„  d   QhR\         /# ©r   r=   ©r!   )r   s   "r   r   r   J   s   € ÷ #ñ #¬ñ #r   c                 ót   € \         P                  ! 4       '       d   \        4       P                  # \	        4       # )zP
Gets the correct log_file path,
adjusting for whether the user is root or not.
)r   Úwe_are_currently_rootr   Úlog_fileÚget_user_log_filer'   r   r   Úget_user_or_root_log_file_pathrf   J   s*   € ô
 ×!Ò!×#Ò#Ü‹z×"Ñ"Ð"ä Ó"Ð"r   c                ó$   € V ^8„  d   QhR\         /# r`   ra   )r   s   "r   r   r   U   s   € ÷ Gñ Gœ3ñ Gr   c                 óh   € \         P                  P                  \        P                  ! 4       R4      # )z/Gets the correct user log_file storage locationúubuntu-pro.log)ÚosÚpathÚjoinr
   Úget_user_cache_dirr'   r   r   re   re   U   s!   € ä�7‰7�<‰<œ×1Ò1Ó3Ð5EÓFÐFr   c                ó:   € V ^8„  d   QhR\         \        ,          /# r`   )r   r!   )r   s   "r   r   r   Z   s   € ÷ ñ ¤¤S¥	ñ r   c                 ó  € \         P                  ! R4      p . pV  Fl  p\         P                  P                  RVR\        P
                  R4      p\         P                  P                  V4      '       g   K[  VP                  V4       Kn  	  V# )ztGets all the log files for the users in the system

Returns a list of all user log files in their home directories.
z/homez.cacheri   )rj   Úlistdirrk   rl   r   ÚUSER_CACHE_SUBDIRÚisfileÚappend)Úuser_directoriesÚ	log_filesÚuser_directoryÚ	user_paths       r   Úget_all_user_log_filesrx   Z   st   € ô
 —z’z 'Ó*ÐØ€IÛ*ˆÜ—G‘G—L‘LØØØÜ×&Ñ&Øó
ˆ	ô �7‰7�>‰>˜)×$Ô$Ø×Ñ˜YÖ'ñ +ð Ðr   c                  ó�  € \         P                  ! R 4      p V P                  \         P                  4       \         P                  ! 4       pVP                  \        4       4       VP                  \         P                  4       VP                  \        4       4       VP                  \        4       4       V P                  V4       R# )Ú	ubuntuproN)r   Ú	getLoggerÚsetLevelÚINFOÚStreamHandlerÚsetFormatterr;   Ú	addFilterr   r3   Ú
addHandler)ÚloggerÚconsole_handlers     r   Úsetup_journald_loggingr„   n   s†   € Ü×Ò˜{Ó+€FØ
‡O�O”G—L‘LÔ!Ü×+Ò+Ó-€OØ× Ñ Ô!3Ó!5Ô6Ø×ÑœWŸ\™\Ô*Ø×ÑÔ2Ó4Ô5Ø×ÑÔ8Ó:Ô;Ø
×Ñ�oÖ&r   c                óR   € V ^8„  d   QhR\         \        \        3,          R\        /# )r   Ú	log_levelrd   )r   r!   Úint)r   s   "r   r   r   y   s"   € ÷ $ñ $¤¤s¬C x¥ð $¼Cñ $r   c                ó´  € \        V \        4      '       d   V P                  4       p \        P                  ! 4       '       g   \        4       p\        P                  ! R4      pVP                  V 4       . Vn	        \        P                  ! V4      pVP                  4       '       g0   VP                  P                  RRR7       VP                  RR7       \        P                   ! V4      pVP#                  \%        4       4       VP                  V 4       VP'                  \)        4       4       VP'                  \+        4       4       VP-                  V4       R# )zgSetup logging to log_file

If run as non-root then log_file is replaced with a user-specific log file.
rz   T)ÚparentsÚexist_oki   )ÚmodeN)rL   r!   Úupperr   rc   re   r   r{   r|   ÚhandlersÚpathlibÚPathÚexistsÚparentÚmkdirÚtouchÚFileHandlerr   r;   r€   r   r3   r�   )r†   rd   r‚   Úlog_file_pathÚfile_handlers   &&   r   Úsetup_cli_loggingr—   y   s  € ô �)œS×!Ò!Ø—O‘OÓ%ˆ	ô ×%Ò%×'Ò'Ü$Ó&ˆä×Ò˜{Ó+€FØ
‡O�O�IÔð €F„Oô —L’L Ó*€MØ×Ñ×!Ò!Ø×Ñ×"Ñ"¨4¸$Ð"Ô?Ø×Ñ ÐÔ'Ü×&Ò& xÓ0€LØ×ÑÔ0Ó2Ô3Ø×Ñ˜)Ô$Ø×ÑÔ/Ó1Ô2Ø×ÑÔ5Ó7Ô8à
×Ñ�lÖ#r   c                 ó
   € RV /# )zƒ
A helper for passing extra fields to log statements.
Usage:
LOG.info("message string", extra=log.extra(field=something_relevant))
rB   r'   )Úkwargss   ,r   rB   rB   š   s   € ð �VÐÐr   )rP   r   rj   rŽ   Úcollectionsr   Útypingr   r   r   r   Úuaclientr   r	   r
   r   Úuaclient.configr   ÚFilterr   r3   Ú	Formatterr;   rf   re   rx   r„   r—   rB   r'   r   r   Ú<module>r       sv   ðÛ Û Û 	Û Ý #ß )Ó )ç ;Ó ;Ý $ô˜7Ÿ>™>ô ô §¡ô ô+;˜×*Ñ*ô +;õ\#õGõ
ò('õ$ôBr   