B s `Öã @sòdZddlmZddlmZddlmZddlZejZejZ ej Z ej Z ejZdZdZdZdZdZd Zed ed ed ed ediZeeeeeedœZeeee ee ee eeiZedd„e ¡DƒƒZdd„Zdd„Zdd„Zdd„Zdd„Z dd„Z!dS)aModule to convert log levels between Abseil Python, C++, and Python standard. This converter has to convert (best effort) between three different logging level schemes: cpp = The C++ logging level scheme used in Abseil C++. absl = The absl.logging level scheme used in Abseil Python. standard = The python standard library logging level scheme. Here is a handy ascii chart for easy mental mapping. LEVEL | cpp | absl | standard | ---------+-----+--------+----------+ DEBUG | 0 | 1 | 10 | INFO | 0 | 0 | 20 | WARNING | 1 | -1 | 30 | ERROR | 2 | -2 | 40 | CRITICAL | 3 | -3 | 50 | FATAL | 3 | -3 | 50 | Note: standard logging CRITICAL is mapped to absl/cpp FATAL. However, only CRITICAL logs from the absl logger (or absl.logging.fatal) will terminate the program. CRITICAL logs from non-absl loggers are treated as error logs with a message prefix "CRITICAL - ". Converting from standard to absl or cpp is a lossy conversion. Converting back to standard will lose granularity. For this reason, users should always try to convert to standard, the richest representation, before manipulating the levels, and then only to cpp or absl if those level schemes are absolutely necessary. é)Úabsolute_import)Údivision)Úprint_functionNéýÿÿÿéþÿÿÿéÿÿÿÿéÚFATALÚERRORÚWARNINGÚINFOÚDEBUG)r r r ÚWARNr r ccs|]\}}||fVqdS)N©)Ú.0ÚkÚvrrú:/tmp/pip-unpacked-wheel-00lyeop_/absl/logging/converter.pyú YsrcCs,|tkr dS|tkrdS|tkr$dSdSdS)aªGets the initial that should start the log line for the given level. It returns: - 'I' when: level < STANDARD_WARNING. - 'W' when: STANDARD_WARNING <= level < STANDARD_ERROR. - 'E' when: STANDARD_ERROR <= level < STANDARD_CRITICAL. - 'F' when: level >= STANDARD_CRITICAL. Args: level: int, a Python standard logging level. Returns: The first initial as it would be logged by the C++ logging module. ÚIÚWÚEÚFN)ÚSTANDARD_WARNINGÚSTANDARD_ERRORÚSTANDARD_CRITICAL)ÚlevelrrrÚget_initial_for_level\srcCs2t|tƒstd t|ƒ¡ƒ‚|dkr(dS| SdS)zçConverts an absl log level to a cpp log level. Args: level: int, an absl.logging level. Raises: TypeError: Raised when level is not an integer. Returns: The corresponding integer level for use in Abseil C++. zExpect an int level, found {}rN)Ú isinstanceÚintÚ TypeErrorÚformatÚtype)rrrrÚ absl_to_cppus r#cCsDt|tƒstd t|ƒ¡ƒ‚|tkr(t}|tkr8t|St|dS)aConverts an integer level from the absl value to the standard value. Args: level: int, an absl.logging level. Raises: TypeError: Raised when level is not an integer. Returns: The corresponding integer level for use in standard logging. zExpect an int level, found {}r) rrr r!r"Ú ABSL_FATALÚ ABSL_DEBUGÚABSL_TO_STANDARDÚSTANDARD_DEBUG)rrrrÚabsl_to_standardŠs r(cCstt | ¡¡ƒS)zàConverts a string level to standard logging level value. Args: level: str, case-insensitive 'debug', 'info', 'warning', 'error', 'fatal'. Returns: The corresponding integer level for use in standard logging. )r(Ú ABSL_NAMESÚgetÚupper)rrrrÚstring_to_standard s r,cCstt|tƒstd t|ƒ¡ƒ‚|dkr(d}|tkr,sL