3 ig -@sddlZddlZddlZddlZddlZddlZddlmZddlmZm Z m Z m Z m Z m Z mZmZddlmZmZddlmZddlmZddlmZy ddlZWnek rddlZYnXyddlmZWnek rdZYnXejZ ed Z!Gd d d eZ"ee#e#e$d d dZ%ej&d&e'e ddddZ(e'dddZ)Gdddej*Z+e,e e,ge,fdddZ-Gdddej.Z/Gdddej0j1Z2Gdd d eZ3Gd!d"d"eZ4e'e$e e,e'd#d$d%Z5dS)'N)Filter)IOAnyCallableIteratorOptionalTextIOTypecast)VERBOSE getLogger)WINDOWS)DEPRECATION_MSG_PREFIX) ensure_dir)coloramazpip.subprocessorc@seZdZdZdS)BrokenStdoutLoggingErrorzO Raised if BrokenPipeError occurs for the stdout stream while logging. N)__name__ __module__ __qualname____doc__rr:/tmp/pip-build-88gy_88q/pip/pip/_internal/utils/logging.pyr!sr) exc_classexcreturncCs0|tkr dStsdSt|to.|jtjtjfkS)NTF)BrokenPipeErrorr isinstanceOSErrorerrnoEINVALEPIPE)rrrrr_is_broken_pipe_error's r!)numrc 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)r#rrr indent_log4s  r')rcCs ttddS)Nr&r)getattrr%rrrrr$Csr$csZeZdZdZddeeeddfddZeeedd d Z e j ed fd d Z Z S)IndentingFormatterz%Y-%m-%dT%H:%M:%SF) add_timestampN)argsr*kwargsrcs||_tj||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. N)r*super__init__)selfr*r+r,) __class__rrr.Js zIndentingFormatter.__init__) formattedlevelnorcCs.|tjkrdS|jtrdS|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/r1r2rrrget_message_startYs   z$IndentingFormatter.get_message_start)recordrcsltj|}|j||j}||}d|jr<|j|ddt7djfdd|jdD}|S)z Calls the standard formatter, but will indent all of the log message lines by our current indentation level. r3 csg|] }|qSrr).0line)prefixrr vsz-IndentingFormatter.format..T) r-formatr8r2r* formatTimer$join splitlines)r/r9r1Z message_start)r0)r=rr?is zIndentingFormatter.format)rrrdefault_time_formatrboolr.strintr8r4 LogRecordr? __classcell__rr)r0rr)Gs   r))colorsrcsttdfdd }|S)N)inprcsdjt|tjjgS)Nr3)rAlistrStyle RESET_ALL)rJ)rIrrwrapped{sz_color_wrap..wrapped)rE)rIrNr)rIr _color_wrapzsrOcseZdZer2ejeejjfej eejj fgZ ngZ de e eddfdd ZedddZeddd Zejed fd d Zejdd fd d ZZS)ColorizedStreamHandlerN)streamno_colorrcs,tj|||_tr(tr(tj|j|_dS)N)r-r. _no_colorr r AnsiToWin32rQ)r/rQrR)r0rrr.s zColorizedStreamHandler.__init__)rcCs.tr"tr"ttj|j}|jtjkS|jtjkS)zA Return whether the handler is using sys.stdout. )r rr rTrQrNsysstdout)r/rQrrr _using_stdouts z$ColorizedStreamHandler._using_stdoutcCsZt s |jrdSt|jtjs$|jn|jj}t|drB|jrBdStj j ddkrVdSdS)NFisattyTTERMANSI) rrSrrQrTrNhasattrrXosenvironget)r/ real_streamrrr should_colors z#ColorizedStreamHandler.should_color)r9rcs@tj|}|jrtj}n|d3krNtj}ntj}tj|}|dk }|rt|}d}nd}|}|d4krd nd}d d d } d dd} dddg|rdgng} tjj dddtjddt j ddt j ddt ddt dddd|| d || d!d"d#gd$d%d | d || d&d"gd$d%|| d || d&d'gd$d%d| d(|d)dd*d+d,|| d-d.d/|iid0|S)5znConfigures and sets up all of the logging Returns the requested logging level, as its integer value. r"NDEBUGz /dev/nullINFOr7r5zext://sys.stdoutzext://sys.stderr)rVstderrz2pip._internal.utils.logging.ColorizedStreamHandlerz5pip._internal.utils.logging.BetterRotatingFileHandler)rQfileconsoleconsole_errorsconsole_subprocessuser_logFz*pip._internal.utils.logging.MaxLevelFilter)z()rczlogging.Filter)z()namez/pip._internal.utils.logging.ExcludeLoggerFilter)exclude_warningsrestrict_to_subprocessexclude_subprocessz %(message)s)z()r?T)z()r?r*)indentindent_with_timestamprQrVrrr)rcclassrRrQfilters formatterrxrryzutf-8r)rcrfilenameencodingdelayr)rzr{r|r})rchandlersz pip._vendorrc)versiondisable_existing_loggersr formattersrrootloggers)rwr7) r4rvr r5r7CRITICALrw getLevelNameconfig dictConfigsubprocess_loggerr~r)) rrrRrsZ level_numberrcZinclude_user_logZadditional_log_file root_levelZvendored_log_level log_streamsZhandler_classesrrrr setup_loggings    r)r")6 contextlibrr4logging.handlersr\rUrZtypingrrrrrrr r Zpip._internal.utils._logr r Zpip._internal.utils.compatr Zpip._internal.utils.deprecationrZpip._internal.utils.miscr threading ImportErrordummy_threading pip._vendorr Exceptionlocalr%rr BaseExceptionrDr!contextmanagerrFr'r$ Formatterr)rErO StreamHandlerrPrRotatingFileHandlerrjrorqrrrrrsB (      3Q