ok
Direktori : /opt/alt/python37/lib/python3.7/site-packages/clcommon/__pycache__/ |
Current File : //opt/alt/python37/lib/python3.7/site-packages/clcommon/__pycache__/cllog.cpython-37.pyc |
B E!wd� � @ sV d dl mZ d dl mZ d dl mZ d dlZd dlZd dlZd dlZG dd� d�ZdS )� )�absolute_import)�division)�print_functionNc @ s* e Zd Zdd� Zd dd�Zedd� �ZdS ) � ClAuditLogc C s || _ d S )N)�_log_file_name)�selfZ log_file_name� r �?/opt/alt/python37/lib/python3.7/site-packages/clcommon/cllog.py�__init__ s zClAuditLog.__init__� c C s� t j �� }t�� }| �|�}yrt| jd�}t�|tj tj B � |�|�d�d | d t |� d t tjdd � � d | d � |�� W n ttfk r� Y nX d S ) N�az%Y.%m.%d %H:%M:%Sz: Parent process: z (PID: z ): Args: � � � )�datetimeZnow�os�getppid�_get_process_name�openr �fcntl�lockfZLOCK_EXZLOCK_NB�writeZstrftime�str�sys�argv�close�IOError�OSError)r �msgZdt_nowZparent_proc_idZ proc_nameZaudit_log_filer r r �info_log_write s BzClAuditLog.info_log_writec C sR d}y<t d| d�}|�� �d�d �dd��dd�}|�� W n Y nX |S ) z\ Get process name by pid :param pid: PID for get process name :return: process name z <Unknown>z /proc/%s/stat�rr r �(r �))r �read�split�replacer )�pid�name�fr r r r * s "zClAuditLog._get_process_nameN)r )�__name__� __module__�__qualname__r r �staticmethodr r r r r r s r ) Z __future__r r r r r r r r r r r r �<module> s