Current File : //usr/lib64/python3.6/site-packages/borg/__pycache__/logger.cpython-36.pyc |
3
y��b�# � @ 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 s( dj |||j| �}tt�}|j|� d S )Nz{0}:{1}: {2}: {3})�format�__name__�
create_logger�warning)�message�category�filename�lineno�file�line�msg�logger� r �/usr/lib64/python3.6/logger.py�_log_warning/ s r �BORG_LOGGING_CONF�infoc C s� d}|rt jj||�}|r�ydt jj|�}t|��}tjj|� W dQ R X da tj
t�}tj
d�} || _|j
dj|�� tt_dS tk
r� }
zt|
�}W Y dd}
~
X nX tj
d�}tj| �}|r�| r�d}nd}|r�t|�ntj|�}
|j|
� tj
d�} |
| _|| _t �r.|j�r.|jd j� |jj� |j|� |j|j� � da tj
t�}|�rl|jd j||�� |j
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 "{0}"� z/$LOG %(levelname)s %(name)s Remote: %(message)sz%(message)sr z*setup_logging for "{0}" failed with "{1}".z,using builtin fallback logging configuration) �os�environ�get�path�abspath�open�logging�configZ
fileConfig�
configured� getLoggerr �json�debugr r �warnings�showwarning� Exception�strZ
StreamHandler�
JsonFormatter� FormatterZsetFormatter� formatterZhandlers�close�clearZ
addHandler�setLevel�upperr )�streamZ
conf_fnameZenv_var�levelZis_server Zerr_msg�fr
Zborg_logger�errZhandlerZfmtr&