File: //lib/python3/dist-packages/certbot/_internal/__pycache__/log.cpython-310.pyc
o
6��a�8 � @ s. d Z ddlZddlZddlZddlZddlZddlZddlZddlm Z ddl
mZ ddlm
Z
ddlmZ ddlmZ ddlmZ dd lmZ d
ZdZe�e�Zdd
� Zdd� Zdd� ZG dd� dej�ZG dd� dejj �Z G dd� dej�Z!dd� Z"de#de$de de%de%de&fd d!�Z'de&fd"d#�Z(dS )$a� Logging utilities for Certbot.
The best way to use this module is through `pre_arg_parse_setup` and
`post_arg_parse_setup`. `pre_arg_parse_setup` configures a minimal
terminal logger and ensures a detailed log is written to a secure
temporary file if Certbot exits before `post_arg_parse_setup` is called.
`post_arg_parse_setup` relies on the parsed command line arguments and
does the full logging setup with terminal and rotating file handling as
configured by the user. Any logged messages before
`post_arg_parse_setup` is called are sent to the rotating file handler.
Special care is taken by both methods to ensure all errors are logged
and properly flushed before program exit.
The `logging` module is useful for recording messages about about what
Certbot is doing under the hood, but do not necessarily need to be shown
to the user on the terminal. The default verbosity is WARNING.
The preferred method to display important information to the user is to
use `certbot.display.util` and `certbot.display.ops`.
� N)�
TracebackType)�IO)�messages)�errors)�util)� constants)�osz%(message)sz.%(asctime)s:%(levelname)s:%(name)s:%(message)sc C s� t � } | �t�t�� | �tj� t| �}t� }|�t�t �� |�t
j� t�� }|�tj� |�
|� |�
|� t�tj� tjt|dtjv dtjv pQdtjv | jd�t_dS )a� Setup logging before command line arguments are parsed.
Terminal logging is setup using
`certbot._internal.constants.QUIET_LOGGING_LEVEL` so Certbot is as quiet as
possible. File logging is setup so that logging messages are
buffered in memory. If Certbot exits before `post_arg_parse_setup`
is called, these buffered messages are written to a temporary file.
If Certbot doesn't exit, `post_arg_parse_setup` writes the messages
to the normal log files.
This function also sets `logging.shutdown` to be called on program
exit which automatically flushes logging handlers and
`sys.excepthook` to properly log/display fatal exceptions.
z--debugz--quietz-q��debug�quiet�log_pathN)�TempHandler�setFormatter�logging� Formatter�FILE_FMT�setLevel�DEBUG�
MemoryHandler�ColoredStreamHandler�CLI_FMTr �QUIET_LOGGING_LEVEL� getLogger�
addHandlerr �atexit_register�shutdown� functools�partial�pre_arg_parse_except_hook�sys�argv�path�
excepthook)�temp_handler�memory_handler�stream_handler�root_logger� r'