관리-도구
편집 파일: up2dateLog.cpython-36.pyc
3 e�$g< � @ sF d dl Z d dlZd dlmZmZ d dlmZ G dd� d�Zdd� ZdS )� N)�ustr�sstr)�configc @ sH e Zd ZdZdd� Zdd� Zdd� Zdd � Zd d� Zdd � Z dd� Z dS )�Logz� attempt to log all interesting stuff, namely, anything that hits the network any error messages, package installs, etc c C s d| _ tj� | _d| _d S )NZup2date� )�appr ZinitUp2dateConfig�cfg�log_info)�self� r � /usr/lib/python3.6/up2dateLog.py�__init__ s zLog.__init__c C s t |�| _d S )N)�strr )r �namer r r �set_app_name s zLog.set_app_namec G s | j d dkr| jd|�� d S )N�debug� �D: )r )r �log_me)r �argsr r r � log_debug s z Log.log_debugc G sd dt jt j � �| jf | _d}x |D ]}tt|��}||7 }q$W | jd dkrVt|� | j|� dS )zHGeneral logging function. Eg: log_me("I am a banana.") z[%s] %sr r r N) �time�ctimer r r r r �print� write_log)r r �s�ir r r r s z Log.log_mec C s@ dt jt j � �| jf | _tj� }djtj|��}| j|� d S )Nz[%s] %sr ) r r r r � traceback� extract_stack�join�format_listr )r �x�msgr r r �trace_me) s zLog.trace_mec C sd dt jt j � �| jf | _dg}|jd� |tjtj|�� }|jd||f � | jdj |�� d S )Nz[%s] %s� z#Traceback (most recent call last): z%s: %s r ) r r r r �appendr r � extract_tbr r )r Zlogtype�value�tb�outputr r r � log_exception/ s zLog.log_exceptionc C sP | j d pd}t|d�}dt| j�t|�f }|jt|�� |j� |j� d S )NZlogFilez/var/log/up2date�az%s %s )r �openr r �writer �flush�close)r r Zlog_nameZlog_filer"