3
ÎÏQ4	  ã            
   @   s€   d Z dZdZddlZddlZdZdZdZdZd	Z	d
Z
dZdZdZdZdZejeeje	ejeejeejeiZG dd„ dejƒZdS )z"
Logging facilities for aptdaemon
z%Sebastian Heinlein <devel@glatzor.de>ÚColoredFormatteré    Né   é   é    é!   é"   é#   é$   é%   z[0mz[1;%dmz[1mc               @   s"   e Zd ZdZddd„Zdd„ ZdS )	r   zŠAdds some color to the log messages.

    http://stackoverflow.com/questions/384076/            how-can-i-color-python-logging-output
    NTc             C   s0   t jj| ||ƒ tjdƒdkr&|| _nd| _d S )NZTERMÚxtermúxterm-coloredÚlinuxF)r   r   r   )ÚloggingÚ	FormatterÚ__init__ÚosÚgetenvÚ	use_color)ÚselfZfmtZdatefmtr   © r   ú2/usr/lib/python3/dist-packages/aptdaemon/logger.pyr   =   s    zColoredFormatter.__init__c             C   sr   | j rd|jtkrdtt|j  |j t |_tt |j t |_|jtj	tj
gkrdtt |j t |_tjj| |ƒS )z"Return the formated output string.)r   ZlevelnoÚCOLORSÚ	COLOR_SEQZ	levelnameÚ	RESET_SEQÚGREENÚnamer   ÚCRITICALÚERRORÚREDÚmsgr   Úformat)r   Úrecordr   r   r   r    D   s    zColoredFormatter.format)NNT)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r    r   r   r   r   r   5   s   
)r%   Ú
__author__Ú__all__r   r   ZBLACKr   r   ZYELLOWZBLUEZMAGENTAZCYANZWHITEr   r   ZBOLD_SEQZWARNÚINFOÚDEBUGr   r   r   r   r   r   r   r   r   Ú<module>   s*   
