HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/landscape/lib/__pycache__/logging.cpython-310.pyc
o

y)�]�	�@sZddlmZddlZddlZddlZddlZdZddd�Zddd	�Zdd
d�Z	dd
�Z
dS)�)�absolute_importNz;%(asctime)s %(levelname)-8s [%(threadName)-10s] %(message)s�infocCsR|jdddddd�d}|r|d�|�7}|jd	d
d||d�|jd
|dd�dS)z?Add common logging-related CLI options to the given arg parser.z-qz--quietF�
store_truez"Do not log to the standard output.)�default�action�helpz)The directory in which to write log filesz (default: {!r}).z-lz	--log-dir�FILE)�metavarrrz--log-levelz/One of debug, info, warning, error or critical.)rrN)�
add_option�format)�parser�level�logdir�
logdirhelp�r�7/usr/lib/python3/dist-packages/landscape/lib/logging.py�add_cli_optionss��
�rFcCsV|dur
tj�tjd�}t�|���}tt�	�|||t�
t�|s$tjnd�t�	�S)z3Given a log dir, set up logging for an application.Nr)
�os�path�basename�sys�argv�logging�getLevelName�upper�
_init_logging�	getLogger�	Formatter�FORMAT�stdout)rr
�progname�quietrrr�init_app_loggings�r"c	Cst|�|�tj�|�st�|�tj�||d�}t�|�g}|r)|�t�	|��|D]}|�
|�|�|�q+dS)Nz.log)�setLevelrr�exists�makedirs�joinr�FileHandler�append�
StreamHandler�
addHandler�setFormatter)	�loggerr
r�logname�	formatterr�filename�handlers�handlerrrrr+s

�
�rc	Csdt��jD]%}t|tj�r*|��z|j��t|j	|j
�|_W|��q|��wqt�d�dS)z�
    This closes and reopens the underlying files in the logging module's
    root logger. If called after logrotate (or something similar) has
    moved the old log file out of the way, this will start writing to a new
    new log file...
    zLandscape Logs rotatedN)
rrr0�
isinstancer'�acquire�stream�close�open�baseFilename�mode�releaser)r1rrr�rotate_logs?s
��r:)rN)rNF)N)�
__future__rrr�os.pathrrrr"rr:rrrr�<module>s