CoolFace
Apppublic

blanchon/Metric3D

sourceHugging Facegpl-3.0updated 2y agoView on Hugging Face
0likes
logger.cpython-39.pyc35 linesDownload Raw Back to __pycache__
1a

2�6�d��@s�ddlZddlZddlZddlZddlZddlZddlmZdgZGdd�dej	�Z3d
dddd�d	d�Zdd4lm
Ze�Z
dd�ZdS)�N)�colored�setup_loggercs(eZdZ�fdd�Z�fdd�Z�ZS)�_ColorfulFormattercsN|�d�d|_|�dd�|_t|j�r4|jd|_tt|�j|i|��dS)N�	root_name�.�abbrev_name�)�pop�5_root_name�_abbrev_name�len�superr�__init__)�self�args�kwargs��	__class__��CC:\Users\JUGG\Documents\GitHub\Metric3DPrivate\mono\utils\logger.pyrs67z_ColorfulFormatter.__init__cs~|j�|j|j�|_tt|��|�}|jtj	krBt8dddgd�}n0|jtjksZ|jtjkrnt9ddddgd�}n|S|d|S)N�WARNING�red�blink)�attrs�ERROR�	underline� )
�name�replacer10rr
r�
formatMessage�levelno�loggingrrr�CRITICAL)r�record�log�prefixrrrrsz _ColorfulFormatter.formatMessage)�__name__�11__module__�__qualname__rr�
__classcell__rrrrrsrZmetricdepthT)r�colorrcCs"t��}|�tj�d|_|dur&d}tjddd�}|dkr�tjtjd�}|�tj�|rzt	t12d	d13�dd|t|�d�}n|}|�|�|�
|�|du�r|�d
�s�|�d�r�|}	ntj�|d�}	|dkr�|	d�|�}	tjtj�|	�dd�t�t|	��}14|15�tj�|16�|�|�
|17�|S)ag18    Initialize the detectron2 logger and set its verbosity level to "DEBUG".19    Args:20        output (str): a file name or a directory to save log. If None, will not save log file.21            If ends with ".txt" or ".log", assumed to be a file name.22            Otherwise, logs will be saved to `output/log.txt`.23        abbrev_name (str): an abbreviation of the module, to avoid log names in logs.24            Set to "" not log the root module in logs.25            By default, will abbreviate "detectron2" to "d2" and leave other26            modules unchanged.27    Returns:28        logging.Logger: a logger29    FN�d2z1[%(asctime)s] %(name)s %(levelname)s %(message)s z%m/%d %H:%M:%S)�datefmtr)�streamz[%(asctime)s %(name)s]: �greenz%(message)s)r,rrz.txtz.logzlog.txtz.rank{}T)�exist_ok)r!�	getLogger�setLevel�INFO�	propagate�	Formatter�
StreamHandler�sys�stdoutrr�str�setFormatter�30addHandler�endswith�os�path�join�format�makedirs�dirname�_cached_log_stream)�outputZdistributed_rankrr*r�loggerZplain_formatter�ch�	formatter�filename�fhrrrrsB��3132333435)�PathManagercCs,tj|dd|vrdndd�}t�|j�|S)N�az://i�����)�	buffering)rI�open�atexit�register�close)rG�iorrrrBasrB)Nr)rNr!r<r6�time�torch�	termcolorr�__all__r4rrZiopath.common.file_iorIZPathManagerBaserBrrrr�<module>s��<