HEX
Server: LiteSpeed
System: Linux shams.tasjeel.ae 5.14.0-611.5.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Nov 11 08:09:09 EST 2025 x86_64
User: infowars (1469)
PHP: 8.2.29
Disabled: NONE
Upload Files
File: //lib64/python3.9/site-packages/borg/__pycache__/logger.cpython-39.pyc
a

HZ�h�#�@s|dZddlZddlZddlZddlZddlZddlZddlZdaddd�Z	ddd	�Z
d
d�Zddd
�ZGdd�dej
�ZdS)alogging 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
�NFcCs2|�d|�d|j�d|��}tt�}|�|�dS)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/sr�BORG_LOGGING_CONF�infoc
Cs�d}|rtj�||�}|r�z|tj�|�}t|��}tj�|�Wd�n1sR0Yda	t�
t�}t�
d�}	||	_|�
d|�d��tt_WdSty�}
zt|
�}WYd}
~
n
d}
~
00t�
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)srzsetup_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�	FormatterZsetFormatter�	formatter�handlers�close�clearZ
addHandler�setLevel�upperr)�streamZ
conf_fnameZenv_var�levelZis_server�err_msg�fr
Zborg_logger�errZhandler�fmtr&rrr�
setup_logging8sN

*









r2cCs\z@t��j}t�|�}|dus(|jtkr:|j}t�|�}q|jWStyVtYS0dS)z�find the name of the first module calling this module

    if we cannot find it, we return the current module's name
    (__name__) instead.
    N)�inspectZcurrentframe�f_backZ	getmoduler�AttributeError)�frame�modulerrr�find_parent_modulews

r8csG�fdd�d���|�S)a�lazily create a Logger object with the proper path, which is returned by
    find_parent_module() by default, or is provided via the commandline

    this is really a shortcut for:

        logger = logging.getLogger(__name__)

    we use it to avoid errors and provide a more standard API.

    We must create the logger lazily, because this is usually called from
    module level (and thus executed at import time - BEFORE setup_logging()
    was called). By doing it lazily we can do the setup first, we just have to
    be careful not to call any logger methods before the setup_logging() call.
    If you try, you'll get an exception.
    csneZdZddd�Zedd��Z�fdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZdS)z!create_logger.<locals>.LazyLoggerNcSs|pt�|_d|_dS�N)r8�_LazyLogger__name�_LazyLogger__real_logger)�self�namerrr�__init__�sz*create_logger.<locals>.LazyLogger.__init__cSsP|jdurJtstd��t�|j�|_|j�d�rJ|jjtjkrJ|j�	d�|jS)Nz8tried to call a logger before setup_logging() was calledzborg.debug.ZWARNING)
r;rr"rrr:�
startswithr-ZNOTSETr*)r<rrrZ__logger�s
z*create_logger.<locals>.LazyLogger.__loggercs�|jd|�S)N�.)r:)r<�suffix��
LazyLoggerrr�getChild�sz*create_logger.<locals>.LazyLogger.getChildc_s|jj|i|��Sr9)�_LazyLogger__loggerr*�r<�args�kwrrrr*�sz*create_logger.<locals>.LazyLogger.setLevelc_s0d|vr|�d�|�di�d<|jj|i|��S�N�msgidZextra)�pop�
setdefaultrE�logrFrrrrM�sz%create_logger.<locals>.LazyLogger.logc_s0d|vr|�d�|�di�d<|jj|i|��SrI)rKrLrE�	exceptionrFrrrrN�sz+create_logger.<locals>.LazyLogger.exceptionc_s0d|vr|�d�|�di�d<|jj|i|��SrI)rKrLrErrFrrrr�sz'create_logger.<locals>.LazyLogger.debugc_s0d|vr|�d�|�di�d<|jj|i|��SrI)rKrLrErrFrrrr�sz&create_logger.<locals>.LazyLogger.infoc_s0d|vr|�d�|�di�d<|jj|i|��SrI)rKrLrErrFrrrr�sz)create_logger.<locals>.LazyLogger.warningc_s0d|vr|�d�|�di�d<|jj|i|��SrI)rKrLrE�errorrFrrrrO�sz'create_logger.<locals>.LazyLogger.errorc_s0d|vr|�d�|�di�d<|jj|i|��SrI)rKrLrE�criticalrFrrrrP�sz*create_logger.<locals>.LazyLogger.critical)N)r�
__module__�__qualname__r>�propertyrErDr*rMrNrrrrOrPrrBrrrC�s

	rCr)r=rrBrr�s8rcs eZdZdZ�fdd�Z�ZS)r$)�	levelnamer=rrJcsJt��|�d|jddd�}|jD]}t||d�}|r"|||<q"t�|�S)NZlog_messagerZCRITICAL)�type�timerrT)�super�formatZcreated�RECORD_ATTRIBUTES�getattrr�dumps)r<�record�data�attr�value��	__class__rrrX�s�

zJsonFormatter.format)rrQrRrYrX�
__classcell__rrr`rr$�sr$)NN)NNrrFF)N)�__doc__r3rrZlogging.configZlogging.handlersrr rrr2r8rr%r$rrrr�<module>s 
	
?
K