File: //lib64/python3.9/site-packages/borg/__pycache__/logger.cpython-39.opt-1.pyc
a
HZ�h�# � @ s| d Z ddlZddlZddlZddlZddlZddlZddlZdaddd�Z ddd �Z
d
d� Zddd
�ZG dd� dej
�ZdS )a logging facilities
The way to use this is as follows:
* each module declares its own logger, using:
from .logger import create_logger
logger = create_logger()
* then each module uses logger.info/warning/debug/etc according to the
level it believes is appropriate:
logger.debug('debugging info for developers or power users')
logger.info('normal, informational output')
logger.warning('warn about a non-fatal error or sth else')
logger.error('a fatal error')
... and so on. see the `logging documentation
<https://docs.python.org/3/howto/logging.html#when-to-use-logging>`_
for more information
* console interaction happens on stderr, that includes interactive
reporting functions like `help`, `info` and `list`
* ...except ``input()`` is special, because we can't control the
stream it is using, unfortunately. we assume that it won't clutter
stdout, because interaction would be broken then anyways
* what is output on INFO level is additionally controlled by commandline
flags
� NFc C s2 |� d|� d|j � d| � �}tt �}|�|� d S )N�:z: )�__name__�
create_logger�warning)�message�category�filename�lineno�file�line�msg�logger� r �1/usr/lib64/python3.9/site-packages/borg/logger.py�_log_warning/ s r �BORG_LOGGING_CONF�infoc
C s� d}|rt j�||�}|r�z|t j�|�}t|��}tj�|� W d � n1 sR0 Y da t�
t�}t�
d�} || _|�
d|� d�� tt_W dS ty� }
zt|
�}W Y d}
~
n
d}
~
0 0 t�
d�}t�| �}|r�|s�d}nd}|r�t|�nt�|�}
|�|
� t�
d�} |
| _|| _t �rF|j�rF|jd �� |j�� |�|� |�|�� � da t�
t�}|�r�|�d
|� d|� d�� |�
d
� tt_|S )a� setup logging module according to the arguments provided
if conf_fname is given (or the config file name can be determined via
the env_var, if given): load this logging configuration.
otherwise, set up a stream handler logger on stderr (by default, if no
stream is provided).
if is_serve == True, we configure a special log format as expected by
the borg client log message interceptor.
NTZborgz'using logging configuration read from "�"� z/$LOG %(levelname)s %(name)s Remote: %(message)sz%(message)sr zsetup_logging for "z" failed with "z".z,using builtin fallback logging configuration)�os�environ�get�path�abspath�open�loggingZconfigZ
fileConfig�
configured� getLoggerr �json�debugr �warnings�showwarning� Exception�strZ
StreamHandler�
JsonFormatter� FormatterZsetFormatter� formatter�handlers�close�clearZ
addHandler�setLevel�upperr )�streamZ
conf_fnameZenv_var�levelZis_server �err_msg�fr
Zborg_logger�errZhandler�fmtr&