U .e2@sddlmZddlZddlZddlZddlZddlZddlZddlmZm Z ddl m Z ddl m Z ddlmZddlmZz ddlZWnek rddlZYnXzddlmZWnek rdZYnXdd lmZeZeZde_e d ZGd d d eZe r&e rd dZ nddZ ne r6ddZ nddZ ej!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?/usr/lib/python3.8/site-packages/pip/_internal/utils/logging.pyr ;sr cCs|tko|jtjtjfkSz1See the docstring for non-Windows Python 3 below.)IOErrorerrnoEINVALEPIPE exc_classexcrrr_is_broken_pipe_errorIsrcCs"|tkp |tko |jtjtjfkSr)BrokenPipeErrorOSErrorrrrrrrrrOscCs|tko|jtjkSr)rrrrrrrrUscCs|tkS)z Return whether an exception is a broken pipe error. Args: exc_class: an exception class. exc: an exception instance. )rrrrrrZsc cs.tj|7_z dVW5tj|8_XdS)zv A context manager which will cause the log output to be indented for any log messages emitted inside it. N) _log_state indentation)Znumrrr indent_loges r cCs ttddS)Nrr)getattrrrrrrget_indentationrsr"cs0eZdZfddZddZfddZZS)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'xszIndentingFormatter.__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}d||jfdt7d 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%s,%03d  csg|] }|qSrr).0lineprefixrr sz-IndentingFormatter.format..T) r&r#formatr4r3r$Z formatTimeZmsecsr"join splitlines)r(recordr2Z message_starttr+r8rr;s zIndentingFormatter.format)r r rr'r4r; __classcell__rrr+rr#vs r#csfdd}|S)Ncsdt|tjjgS)Nr-)r<listr ZStyleZ RESET_ALL)Zinpcolorsrrwrappedsz_color_wrap..wrappedr)rCrDrrBr _color_wraps rEcsheZdZer.ejeejfej eej fgZ ngZ d ddZ ddZ ddZdd Zfd d ZZS) ColorizedStreamHandlerNcCs.tj||||_tr*tr*t|j|_dSN)r. StreamHandlerr' _no_colorrr AnsiToWin32stream)r(rKno_colorrrrr'szColorizedStreamHandler.__init__cCs"trtr|jjtjkS|jtjkS)zA Return whether the handler is using sys.stdout. )rr rKrDsysstdoutr(rrr _using_stdoutsz$ColorizedStreamHandler._using_stdoutcCsXtr |jrdSt|jtjs"|jn|jj}t|dr@|r@dStj ddkrTdSdS)NFisattyTZTERMZANSI) r rI isinstancerKrJrDhasattrrQosenvironget)r(Z real_streamrrr should_colors z#ColorizedStreamHandler.should_colorcCs@tj||}|r<|jD]\}}|j|kr||}qmsglevelZcolorrrrr;s zColorizedStreamHandler.formatcs@tdd\}}|r0|r0t||r0ttt||S)Nr)rMexc_inforPrr r&rF handleError)r(r>rrr+rrr\s  z"ColorizedStreamHandler.handleError)NN)r r rr r.r1rEr ZREDr/ZYELLOWrXr'rPrWr;r\r@rrr+rrFs   rFc@seZdZddZdS)BetterRotatingFileHandlercCs ttj|jtjj|SrG) rrTpathdirnameZ baseFilenamer.handlersRotatingFileHandler_openrOrrrrbszBetterRotatingFileHandler._openN)r r rrbrrrrr]sr]c@seZdZddZddZdS)MaxLevelFiltercCs ||_dSrG)rZ)r(rZrrrr'szMaxLevelFilter.__init__cCs |j|jkSrG)r3rZr(r>rrrfilterszMaxLevelFilter.filterN)r r rr'rerrrrrcsrccs eZdZdZfddZZS)ExcludeLoggerFilterzQ A logging Filter that excludes records from a logger (or its children). cstt|| SrG)r&rfrerdr+rrreszExcludeLoggerFilter.filter)r r rrrer@rrr+rrf srfc 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/r1ZCRITICALINFONz /dev/null)rlr1zext://sys.stdoutzext://sys.stderr)rNstderrz2pip._internal.utils.logging.ColorizedStreamHandlerz5pip._internal.utils.logging.BetterRotatingFileHandler)rKfileconsoleconsole_errorsconsole_subprocessuser_logFz*pip._internal.utils.logging.MaxLevelFilter)()rZzlogging.Filter)rsnamez/pip._internal.utils.logging.ExcludeLoggerFilter)exclude_warningsrestrict_to_subprocessexclude_subprocessz %(message)s)rsr;T)rsr;r$)indentindent_with_timestamprKrNrwrurx)rZclassrLrKfilters formatterrmrvrnry)rZrzfilenameZdelayr|)rorprqrr)rZr`z pip._vendorrZ)versionZdisable_existing_loggersr{Z formattersr`rootZloggers)r!r.ZconfigZ dictConfigr/subprocess_loggerrtr#) verbosityrLZ user_log_filerZZ level_numberZinclude_user_logZadditional_log_fileZ root_levelZvendored_log_levelZ log_streamsZhandler_classesr`rrr setup_loggings      $Jr)r)/Z __future__r contextlibrr.Zlogging.handlersrTrMrrZpip._vendor.sixrZpip._internal.utils.compatrZpip._internal.utils.deprecationrZpip._internal.utils.miscrZ threading ImportErrorZdummy_threadingZ pip._vendorr Z _colorama ExceptionZpip._vendor.coloramar Zlocalrrrr rcontextmanagerr r"Z Formatterr#rErHrFr`rar]rcrfrrrrrsT              2K