Spamworldpro Mini Shell
Spamworldpro


Server : Apache/2.4.62 (Unix) OpenSSL/1.0.2k-fips
System : Linux server1.richineiserver.com 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
User : fdshops ( 1003)
PHP Version : 8.2.21
Disable Function : NONE
Directory :  /lib/python2.7/site-packages/certbot/_internal/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python2.7/site-packages/certbot/_internal/log.pyc
�
���_c@s]dZddlmZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZddlm
Z
ddlmZddlmZddlmZd	Zd
Zeje�Zd�Zd�Zd
�Zdejfd��YZdejjfd��YZdejfd��YZd�Z d�Z!d�Z"dS(s�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 INFO.

The preferred method to display important information to the user is to
use `certbot.display.util` and `certbot.display.ops`.

i����(tprint_functionN(tmessages(terrors(tutil(t	constants(toss%(message)ss.%(asctime)s:%(levelname)s:%(name)s:%(message)scCs�t�}|jtjt��|jtj�t|�}t�}|jtjt	��|jt
j�tj�}|jtj�|j
|�|j
|�tjtj�tjt|ddtjkd|j�t_dS(s�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.

    tdebugs--debugtlog_pathN(tTempHandlertsetFormattertloggingt	FormattertFILE_FMTtsetLeveltDEBUGt
MemoryHandlertColoredStreamHandlertCLI_FMTRtQUIET_LOGGING_LEVELt	getLoggert
addHandlerRtatexit_registertshutdownt	functoolstpartialtpre_arg_parse_except_hooktsystargvtpatht
excepthook(ttemp_handlertmemory_handlertstream_handlertroot_logger((s9/usr/lib/python2.7/site-packages/certbot/_internal/log.pytpre_arg_parse_setup.s		

	cCswt|dt�\}}tjj|�}tj�}d	}}xA|jD]6}t	|t
�rh|}qJt	|t�rJ|}qJqJWd}|d	k	r�|d	k	s�t|��|j
|�|j|�|j}	|j|�|jdt�|j�|	j�|jrtj}
n|jd}
|j|
�tjd|
�tjd|�tjtd|jd|�t_ d	S(
s�Setup logging after command line arguments are parsed.

    This function assumes `pre_arg_parse_setup` was called earlier and
    the root logging configuration has not been modified. A rotating
    file logging handler is created and the buffered log messages are
    sent to that handler. Terminal logging output is set to the level
    requested by the user.

    :param certbot.interface.IConfig config: Configuration object

    sletsencrypt.logs9Previously configured logging handlers have been removed!tforcei
sRoot logging level set at %dsSaving debug log to %sRRN(!tsetup_log_file_handlerRRRtdirnameR
RtNonethandlerst
isinstanceRRtAssertionErrorRt
removeHandlerttargett	setTargettflushtTruetclosetquietRRt
verbose_countR
tloggerRtinfoRRtpost_arg_parse_except_hookRR(tconfigtfile_handlert	file_pathtlogs_dirR!Rtstderr_handlerthandlertmsgRtlevel((s9/usr/lib/python2.7/site-packages/certbot/_internal/log.pytpost_arg_parse_setupTs6
	
$

	


	
cCs�tj|jd|j�tjj|j|�}y%tjj	|ddd|j
�}Wn.tk
r�}tj
tjj|���nX|j�|jtj�tjd|�}|j|�||fS(sSetup file debug logging.

    :param certbot.interface.IConfig config: Configuration object
    :param str logfile: basename for the log file
    :param str fmt: logging format string

    :returns: file handler and absolute path to the log file
    :rtype: tuple

    i�tmaxBytesiitbackupCounttfmti(Rtset_up_core_dirR8tstrict_permissionsRRtjoinR
R'tRotatingFileHandlertmax_log_backupstIOErrorRtErrortPERM_ERR_FMTtformatt
doRolloverR
RRR	(R5tlogfileR@t
log_file_pathR:terrorthandler_formatter((s9/usr/lib/python2.7/site-packages/certbot/_internal/log.pyR$�s
	

RcBs#eZdZdd�Zd�ZRS(s6Sends colored logging output to a stream.

    If the specified stream is not a tty, the class works like the
    standard `logging.StreamHandler`. Default red_level is
    `logging.WARNING`.

    :ivar bool colored: True if output should be colored
    :ivar bool red_level: The level at which to output

    cCsPtt|�j|�|dkr1tjj�n	|j�|_tj	|_
dS(N(tsuperRt__init__R&RtstderrtisattytcoloredR
tWARNINGt	red_level(tselftstream((s9/usr/lib/python2.7/site-packages/certbot/_internal/log.pyRP�scCsStt|�j|�}|jrO|j|jkrOdjtj|tj	f�S|S(s�Formats the string representation of record.

        :param logging.LogRecord record: Record to be formatted

        :returns: Formatted, string representation of record
        :rtype: str

        t(
RORRIRStlevelnoRURCRtANSI_SGR_REDtANSI_SGR_RESET(RVtrecordtout((s9/usr/lib/python2.7/site-packages/certbot/_internal/log.pyRI�s	N(t__name__t
__module__t__doc__R&RPRI(((s9/usr/lib/python2.7/site-packages/certbot/_internal/log.pyR�s
RcBs;eZdZddd�Zd�Zed�Zd�ZRS(s�Buffers logging messages in memory until the buffer is flushed.

    This differs from `logging.handlers.MemoryHandler` in that flushing
    only happens when flush(force=True) is called.

    i'cCs tt|�j|d|�dS(NR+(RORRP(RVR+tcapacity((s9/usr/lib/python2.7/site-packages/certbot/_internal/log.pyRP�scCs)|j}tt|�j�||_dS(s;Close the memory handler, but don't set the target to None.N(R+RORR/(RVR+((s9/usr/lib/python2.7/site-packages/certbot/_internal/log.pyR/�s	cCs |rtt|�j�ndS(s�Flush the buffer if force=True.

        If force=False, this call is a noop.

        :param bool force: True if the buffer should be flushed.

        N(RORR-(RVR#((s9/usr/lib/python2.7/site-packages/certbot/_internal/log.pyR-�s
cCstS(s�Should the buffer be automatically flushed?

        :param logging.LogRecord record: log record to be considered

        :returns: False because the buffer should never be auto-flushed
        :rtype: bool

        (tFalse(RVR\((s9/usr/lib/python2.7/site-packages/certbot/_internal/log.pytshouldFlush�s	N(	R^R_R`R&RPR/RbR-Rc(((s9/usr/lib/python2.7/site-packages/certbot/_internal/log.pyR�s
	
RcBs)eZdZd�Zd�Zd�ZRS(sSafely logs messages to a temporary file.

    The file is created with permissions 600. If no log records are sent
    to this handler, the temporary file is deleted when the handler is
    closed.

    :ivar str path: file system path to the temporary log file

    cCsktj�|_tjj|jd�|_tj|jdddd�}tt	|�j
|�t|_dS(Ntlogtmodetwtchmodi�(
ttempfiletmkdtempt_workdirRRRCRt	safe_openRORRPR.t_delete(RVRW((s9/usr/lib/python2.7/site-packages/certbot/_internal/log.pyRP�s
cCs#t|_tt|�j|�dS(slLog the specified logging record.

        :param logging.LogRecord record: Record to be formatted

        N(RbRlRORtemit(RVR\((s9/usr/lib/python2.7/site-packages/certbot/_internal/log.pyRm�s	cCse|j�zI|jj�|jr6tj|j�nt|_tt	|�j�Wd|j
�XdS(suClose the handler and the temporary log file.

        The temporary log file is deleted if it wasn't used.

        N(tacquireRWR/RltshutiltrmtreeRjRbRORtrelease(RV((s9/usr/lib/python2.7/site-packages/certbot/_internal/log.pyR/s

		(R^R_R`RPRmR/(((s9/usr/lib/python2.7/site-packages/certbot/_internal/log.pyR�s				cOs)zt||�Wd|jdt�XdS(sA simple wrapper around post_arg_parse_except_hook.

    The additional functionality provided by this wrapper is the memory
    handler will be flushed before Certbot exits. This allows us to
    write logging messages to a temporary file if we crashed before
    logging was fully configured.

    Since sys.excepthook isn't called on SystemExit exceptions, the
    memory handler will not be flushed in this case which prevents us
    from creating temporary log files when argparse exits because a
    command line argument was invalid or -h, --help, or --version was
    provided on the command line.

    :param MemoryHandler memory_handler: memory handler to flush
    :param tuple args: args for post_arg_parse_except_hook
    :param dict kwargs: kwargs for post_arg_parse_except_hook

    NR#(R4R-R.(Rtargstkwargs((s9/usr/lib/python2.7/site-packages/certbot/_internal/log.pyRsc	CsJ|||f}|s%t|t�r|tjtjks=t�|tkrftj	d�t
jd�ntj	dd|�n�tjdd|�t|t
j�r�tj	t|��t
jd�ntj	d�tj|�rt|�jd�\}}}tj	|�n.tj||�}tj	dj|�j��t|�dS(	s!Logs fatal exceptions and reports them to the user.

    If debug is True, the full exception and traceback is shown to the
    user, otherwise, it is suppressed. sys.exit is always called with a
    nonzero status.

    :param type exc_type: type of the raised exception
    :param BaseException exc_value: raised exception
    :param traceback trace: traceback of where the exception was raised
    :param bool debug: True if the traceback should be shown to the user
    :param str log_path: path to file or directory containing the log

    sExiting due to user request.isExiting abnormally:texc_infosAn unexpected error occurred:s:: RXN(t
issubclasst	ExceptionRRR
tERRORR)tKeyboardInterruptR2RMRtexitRRRGtstrRt
is_acme_errort	partitiont	tracebacktformat_exception_onlyRCtrstriptexit_with_log_path(	texc_typet	exc_valuettraceRRRtt_texc_strtoutput((s9/usr/lib/python2.7/site-packages/certbot/_internal/log.pyR45s$

cCs\d}tjj|�r.|dj|�7}n|dj|�7}|d7}tj|�dS(s�Print a message about the log location and exit.

    The message is printed to stderr and the program will exit with a
    nonzero status.

    :param str log_path: path to file or directory containing the log

    sPlease see the slogfiles in {0} slogfile '{0}' sfor more details.N(RRtisdirRIRRy(RR;((s9/usr/lib/python2.7/site-packages/certbot/_internal/log.pyR�cs	
(#R`t
__future__RRR
tlogging.handlersRoRRhR}tacmeRtcertbotRRtcertbot._internalRtcertbot.compatRRRRR^R2R"R=R$t
StreamHandlerRR'RRRR4R�(((s9/usr/lib/python2.7/site-packages/certbot/_internal/log.pyt<module>s2	&	.	 ,-		.

Spamworldpro Mini