%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/uaclient/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/uaclient/__pycache__/log.cpython-312.pyc

�

��>f���4�ddlZddlZddlZddlZddlmZddlmZmZm	Z	m
Z
ddlmZm
Z
mZmZddlmZGd�dej$�ZGd�d	ej$�ZGd
�dej*�Zdefd
�Zdefd�Zde	efd�Zd�Zde
eefdefd�Zy)�N)�OrderedDict)�Any�Dict�List�Union)�defaults�secret_manager�system�util)�UAConfigc�0�eZdZdZdej
fd�Zy)�RegexRedactionFilter�,A logging filter to redact confidential info�recordc�^�tjt|j��|_y�NT)r�redact_sensitive_logs�str�msg��selfrs  �./usr/lib/python3/dist-packages/uaclient/log.py�filterzRegexRedactionFilter.filters���/�/��F�J�J��@��
��N��__name__�
__module__�__qualname__�__doc__�logging�	LogRecordr�rrrr���6��W�.�.�rrc�0�eZdZdZdej
fd�Zy)�KnownSecretRedactionFilterrrc�r�tjjt|j��|_yr)r	�secrets�redact_secretsrrrs  rrz!KnownSecretRedactionFilter.filters%��#�+�+�:�:�3�v�z�z�?�K��
�rNrr"rrr%r%r#rr%c�@�eZdZdZdZdZdZdejde	fd�Z
y)	�JsonArrayFormatterzYJson Array Formatter for our logging mechanism
    Custom made for Pro logging needs
    z%Y-%m-%dT%H:%M:%Sz%s.%03d)�asctime�	levelname�name�funcName�lineno�messager�returnc��|j�|_|j|�|_i}|jr|j|j�|d<|j
d�s|jr|j|d<|jr|j|j�|d<|jj
d�}|r!t|t�r|j|�t�}|jD]"}|jj
|�}|||<�$||d<t!j"t%|j'���S)N�exc_info�
stack_info�extra)�
getMessager0�
formatTimer+r3�formatException�get�exc_textr4�formatStack�__dict__�
isinstance�dict�updater�required_fields�json�dumps�list�values)rr�extra_message_dictr5�local_log_record�field�values       r�formatzJsonArrayFormatter.format,s2���*�*�,�������0������?�?�-1�-A�-A����.��z�*�"�%�%�j�1�f�o�o�-3�_�_��z�*����/3�/?�/?��!�!�0��|�,����#�#�G�,���Z��t�,��%�%�e�,�'�=���)�)�	,�E��O�O�'�'��.�E�&+��U�#�	,�%7���!��z�z�$�/�6�6�8�9�:�:rN)rrrr�default_time_format�default_msec_formatr@r r!rrIr"rrr*r*s5���.��#���O�;�W�.�.�;�3�;rr*r1c�f�tj�rt�jSt	�S)z\
    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"rr�get_user_or_root_log_file_pathrPJs'��
�!�!�#��z�"�"�"� �"�"rc�f�tjjtj�d�S)z/Gets the correct user log_file storage location�ubuntu-pro.log)�os�path�joinr
�get_user_cache_dirr"rrrOrOUs!��
�7�7�<�<��1�1�3�5E�F�Frc��tjd�}g}|D]d}tjjd|dtj
d�}tjj
|�s�T|j|��f|S)z|Gets all the log files for the users in the system

    Returns a list of all user log files in their home directories.
    z/homez.cacherR)rS�listdirrTrUr�USER_CACHE_SUBDIR�isfile�append)�user_directories�	log_files�user_directory�	user_paths    r�get_all_user_log_filesr`Zsv��
�z�z�'�*���I�*�	(���G�G�L�L�����&�&��
�	��7�7�>�>�)�$����Y�'�	(��rc��tjd�}|jtj�tj�}|jt
��|jtj�|jt��|jt��|j|�y)N�	ubuntupro)r �	getLogger�setLevel�INFO�
StreamHandler�setFormatterr*�	addFilterrr%�
addHandler)�logger�console_handlers  r�setup_journald_loggingrlns���
�
�
�{�
+�F�
�O�O�G�L�L�!��+�+�-�O�� � �!3�!5�6����W�\�\�*����2�4�5����8�:�;�
���o�&r�	log_levelrNc��t|t�r|j�}tj�s
t�}t
jd�}|j|�g|_	tj|�}|j�s/|jjdd��|jd��t
j |�}|j#t%��|j|�|j't)��|j't+��|j-|�y)zoSetup logging to log_file

    If run as non-root then log_file is replaced with a user-specific log file.
    rbT)�parents�exist_oki�)�modeN)r=r�upperrrMrOr rcrd�handlers�pathlib�Path�exists�parent�mkdir�touch�FileHandlerrgr*rhrr%ri)rmrNrj�
log_file_path�file_handlers     r�setup_cli_loggingr}ys����)�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)rAr rSrt�collectionsr�typingrrrr�uaclientrr	r
r�uaclient.configr�Filterrr%�	Formatterr*rrPrOr`rl�intr}r"rr�<module>r�s�����	��#�)�)�;�;�$��7�>�>�������+;��*�*�+;�\#��#�G�3�G�
��S�	��('�$��s�C�x��$�C�$r

Zerion Mini Shell 1.0