ok

Mini Shell

Direktori : /opt/cloudlinux/venv/lib/python3.11/site-packages/clwpos/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib/python3.11/site-packages/clwpos/__pycache__/logsetup.cpython-311.pyc

�

�2�f����ddlmZddlZddlZddlZddlmZddlmZddlm	Z	m
Z
mZddlm
Z
dZdZej�d	ed
��Zejejefd�Zdd�Zdd
�Zd�Zd�ZGd�dej��ZdS)�)�absolute_importN)�
StreamHandler)�RotatingFileHandler)�PROJECT_NAME�
SENTRY_DSN�PKG_VERSION)�init_sentry_clientz/var/log/clwpos/main.logz.clwposz	{homedir}zmain.logc�F�tj��}|dkrEtj|��}t�|j���}ddlm}||��tj
�tj��tj
|��}td�|jD����}td�|jD����}	|	s"|�t#|����|s#|�t%||����|S)z�
    Sets up logger and return it to the caller
    :param str caller_name:
    :param console_level:
    :param file_level:
    :return logging.Logger: log, initialized
    r)�homedir)�create_clwpos_dir_if_not_existsc�<�g|]}t|t���d��S�T)�
isinstancer��.0�handlers  �F/opt/cloudlinux/venv/lib64/python3.11/site-packages/clwpos/logsetup.py�
<listcomp>z!setup_logging.<locals>.<listcomp>2s(��Y�Y�Y�'�
�7�DW�0X�0X�Y��Y�Y�Y�c�<�g|]}t|t���d��Sr)rrrs  rrz!setup_logging.<locals>.<listcomp>5s'��S�S�S�'�
�7�M�0R�0R�S��S�S�Sr)�os�geteuid�pwd�getpwuid�USER_LOGFILE_PATH�format�pw_dir�clwpos.utilsr�logging�root�setLevel�DEBUG�	getLogger�any�handlers�
addHandler�get_console_log_handler�get_file_log_handler)
�caller_name�
console_level�
file_level�logfile_path�euid�pwr�logger�has_file_log�has_console_logs
          r�
setup_loggingr2s%���:�<�<�D��q�y�y�
�\�$�
�
��(�/�/��	�/�B�B��@�@�@�@�@�@�'�'��+�+�+��L���'�-�(�(�(�
�
�{�
+�
+�F��Y�Y�V�_�Y�Y�Y���L��S�S�V�_�S�S�S���O��B����1�-�@�@�A�A�A��J����.�z�<�H�H�I�I�I��Mrc��|pt}	|�d��}|d}|d�d��}n#t$r|}d}YnwxYw||fS)z<
    Strips platform-dependent part of package version.
    z.elr��
cloudlinuxT)r�split�endswith�
IndexError)�pkg_version�version�release�is_developers    r�get_package_versionr=?s����,��K���#�#�E�*�*���!�*��"�1�:�.�.�|�<�<�<�������������������L� � s�9A�A�Ac��t��\}}	tt|t���}|rdnd|_t
|jd<dS#t$r6}|r)|�dt|����Yd}~dSYd}~dSd}~wwxYw)zL
    Inits sentry safely, do not break all functionality if init failed
    )r;�dsn�Development�Release�full_versionzError during sentry init: %sN)
r=r	rr�environmentr�tags�	Exception�warning�str)r/r:�is_development�sentry�es     r�init_wpos_sentry_safelyrKNs���2�3�3��G�^�C�#�L�'�z�R�R�R��.<�K�]�]�)���&1���N�#�#�#���C�C�C��	C��N�N�9�3�q�6�6�B�B�B�B�B�B�B�B�B�	C�	C�	C�	C�	C�	C�����C���s�6A�
B�%B�Bc���tj�|��setjd��}	t	|d�����tj|��n#tj|��wxYwtj|d��t|dd���}tj	d���}|�
|��|�|��|S)	N�?�wi�i�)�maxBytes�backupCount�3%(asctime)s: (%(name)s) [%(levelname)s] %(message)s��fmt)r�path�lexists�umask�open�close�chmodrr�	Formatter�setFormatterr!)r+r,�umask_saved�file_log�	formatters     rr(r(]s���
�7�?�?�<�(�(�"��h�t�n�n��	"���s�#�#�)�)�+�+�+��H�[�!�!�!�!��B�H�[�!�!�!�!�����H�\�5�!�!�!�"�<�+�ST�U�U�U�H��!�A����I�
���)�$�$�$����j�!�!�!��Os�"A,�,Bc��tj��}tjd���}|�|��|�|��|S)NrRrS)rrr[r\r!)r*�console_log�formatter_consoles   rr'r'os\���'�)�)�K��)�A��������.�/�/�/�����'�'�'��rc���eZdZ�fd�Z�xZS)�
NullLoggerc���tt|���d��tj��}|�|��dS)N�null_logger)�superrd�__init__r�NullHandlerr&)�self�nh�	__class__s  �rrhzNullLogger.__init__{sG���
�j�$���(�(��7�7�7�
�
 �
"�
"����������r)�__name__�
__module__�__qualname__rh�
__classcell__)rls@rrdrdys8���������������rrd)N)�
__future__rrrrr�logging.handlersr�clwpos.constantsrrr�clsentryr	�ADMIN_LOGFILE_PATH�
USER_WPOS_DIRrU�joinr�CRITICAL�INFOr2r=rKr(r'�Loggerrd�rr�<module>r|sP��'�&�&�&�&�&�����	�	�	�	�
�
�
�
�!�!�!�!�!�!�0�0�0�0�0�0�B�B�B�B�B�B�B�B�B�B�'�'�'�'�'�'�/���
��G�L�L��m�Z�H�H��
�&��<�'�	#�#�#�#�L!�!�!�!�C�C�C�C����$��������������r

Zerion Mini Shell 1.0