B Re%3@sddlmZddlZddlZddlZddlZddlZddlZddlmZm Z ddl m Z ddl m Z ddlmZddlmZy ddlZWnek rddlZYnXyddlmZWnek rdZYnXdd lmZeZeZe d ZGd d d eZe r e rd dZnddZne r0ddZnddZej d%ddZ!ddZ"Gdddej#Z$ddZ%Gdddej&Z'Gdddej(j)Z*Gdd d eZ+Gd!d"d"eZ,d#d$Z-dS)&)absolute_importN)Filter getLogger)PY2)WINDOWS)DEPRECATION_MSG_PREFIX) ensure_dir)colorama)Forezpip.subprocessorc@seZdZdZdS)BrokenStdoutLoggingErrorzO Raised if BrokenPipeError occurs for the stdout stream while logging. N)__name__ __module__ __qualname____doc__rr/builddir/build/BUILDROOT/alt-python37-pip-20.2.4-6.el8.x86_64/opt/alt/python37/lib/python3.7/site-packages/pip/_internal/utils/logging.pyr :sr cCs|tko|jtjtjfkS)z1See the docstring for non-Windows Python 3 below.)IOErrorerrnoEINVALEPIPE) exc_classexcrrr_is_broken_pipe_errorHsrcCs"|tkp |tko |jtjtjfkS)z1See the docstring for non-Windows Python 3 below.)BrokenPipeErrorOSErrorrrr)rrrrrrNscCs|tko|jtjkS)z1See the docstring for non-Windows Python 3 below.)rrr)rrrrrrTscCs|tkS)z Return whether an exception is a broken pipe error. Args: exc_class: an exception class. exc: an exception instance. )r)rrrrrrYsc cs6tt_tj|7_z dVWdtj|8_XdS)zv A context manager which will cause the log output to be indented for any log messages emitted inside it. N)get_indentation _log_state indentation)numrrr indent_logds  r cCs ttddS)Nrr)getattrrrrrrrssrcs0eZdZfddZddZfddZZS)IndentingFormattercs$|dd|_tt|j||dS)z A logging.Formatter that obeys the indent_log() context manager. :param add_timestamp: A bool indicating output lines should be prefixed with their record's timestamp. add_timestampFN)popr#superr"__init__)selfargskwargs) __class__rrr&yszIndentingFormatter.__init__cCs.|tjkrdS|trdS|tjkr*dSdS)zv Return the start of the formatted log message (not counting the prefix to add to each line). z WARNING: zERROR: )loggingWARNING startswithrERROR)r' formattedlevelnorrrget_message_starts   z$IndentingFormatter.get_message_startcsztt||}|||j}||}d|jrJ||d}djftdt7d fdd| dD}|S)z Calls the standard formatter, but will indent all of the log message lines by our current indentation level. r+z%Y-%m-%dT%H:%M:%Sz{t},{record.msecs:03.0f}  csg|] }|qSrr).0line)prefixrr sz-IndentingFormatter.format..T) r%r"formatr2r1r# formatTimelocalsrjoin splitlines)r'recordr0 message_startt)r*)r6rr8s  zIndentingFormatter.format)r r rr&r2r8 __classcell__rr)r*rr"ws r"csfdd}|S)Ncsdt|tjjgS)Nr+)r;listr Style RESET_ALL)inp)colorsrrwrappedsz_color_wrap..wrappedr)rErFr)rEr _color_wraps rGcsheZdZer.ejeejfej eej fgZ ngZ d ddZ ddZ ddZdd Zfd d ZZS) ColorizedStreamHandlerNcCs.tj||||_tr*tr*t|j|_dS)N)r, StreamHandlerr& _no_colorrr AnsiToWin32stream)r'rLno_colorrrrr&szColorizedStreamHandler.__init__cCs"trtr|jjtjkS|jtjkS)zA Return whether the handler is using sys.stdout. )rr rLrFsysstdout)r'rrr _using_stdoutsz$ColorizedStreamHandler._using_stdoutcCsXtr |jrdSt|jtjs"|jn|jj}t|dr@|r@dStj ddkrTdSdS)NFisattyTTERMANSI) r rJ isinstancerLrKrFhasattrrQosenvironget)r' real_streamrrr should_colors z#ColorizedStreamHandler.should_colorcCsBtj||}|r>x&|jD]\}}|j|kr||}PqW|S)N)r,rIr8rZCOLORSr1)r'r=msglevelcolorrrrr8s zColorizedStreamHandler.formatcs@tdd\}}|r0|r0t||r0ttt||S)Nr)rNexc_inforPrr r%rH handleError)r'r=rr)r*rrr`s   z"ColorizedStreamHandler.handleError)NN)r r rr r,r/rGr REDr-YELLOWr[r&rPrZr8r`r@rr)r*rrHs   rHc@seZdZddZdS)BetterRotatingFileHandlercCs ttj|jtjj|S)N) rrVpathdirname baseFilenamer,handlersRotatingFileHandler_open)r'rrrriszBetterRotatingFileHandler._openN)r r rrirrrrrcsrcc@seZdZddZddZdS)MaxLevelFiltercCs ||_dS)N)r])r'r]rrrr&szMaxLevelFilter.__init__cCs |j|jkS)N)r1r])r'r=rrrfilterszMaxLevelFilter.filterN)r r rr&rkrrrrrjsrjcs eZdZdZfddZZS)ExcludeLoggerFilterzQ A logging Filter that excludes records from a logger (or its children). cstt|| S)N)r%rlrk)r'r=)r*rrrkszExcludeLoggerFilter.filter)r r rrrkr@rr)r*rrl srlc Csf|dkrd}n.|dkrd}n |dkr*d}n|dkr8d}nd }tt|}|d k }|r\|}d}nd }|}|d krpdnd}d dd} ddd} dddg|rdgng} tjdddtjddtjddtjddtddtdd d!d"|| d#|| d$d%d&gd'd(d| d#|| d)d%gd'd(|| d#|| d)d*gd'd(d| d+|d d,d-d.|| d/d0d1|iid2|S)3znConfigures and sets up all of the logging Returns the requested logging level, as its integer value. DEBUGr-r/CRITICALINFONz /dev/null)rsr/zext://sys.stdoutzext://sys.stderr)rOstderrz2pip._internal.utils.logging.ColorizedStreamHandlerz5pip._internal.utils.logging.BetterRotatingFileHandler)rLfileconsoleconsole_errorsconsole_subprocessuser_logFz*pip._internal.utils.logging.MaxLevelFilter)z()r]zlogging.Filter)z()namez/pip._internal.utils.logging.ExcludeLoggerFilter)exclude_warningsrestrict_to_subprocessexclude_subprocessz %(message)s)z()r8T)z()r8r#)indentindent_with_timestamprLrOr}r{r~)r]classrMrLfilters formatterrtr|rur)r]rfilenamedelayr)rvrwrxry)r]rgz pip._vendorr])versiondisable_existing_loggersr formattersrgrootloggers)r!r,config dictConfigr-subprocess_loggerrzr") verbosityrM user_log_filer] level_numberinclude_user_logadditional_log_file root_levelvendored_log_level log_streamshandler_classesrgrrr setup_loggings    r)r). __future__r contextlibrr,logging.handlersrVrNrrZpip._vendor.sixrpip._internal.utils.compatrpip._internal.utils.deprecationrpip._internal.utils.miscr threading ImportErrorZdummy_threading pip._vendorr _colorama ExceptionZpip._vendor.coloramar localrrr rcontextmanagerr r Formatterr"rGrIrHrgrhrcrjrlrrrrrsR              2K