
                  
       n   S r SSKJr  SSKJr  SSKJr  SSKrSSKrSSKrSSKrSSK	r	SSK
r
SSKrSSKrSSKrSSKrSSKrSSKrSSKrSSKrSSKJr  SSKJr  SSKJr  SSKr\R4                  (       a  SSKrOSSKr SS	KJr  \RB                  r!\RD                  r#\RH                  r%\RL                  r'\RL                  r(\RR                  r*\RV                  r,S
r-S\R\                  " S5      S-  -  S-
  r/Sr0Sr1\
Rd                  Rg                  SS5      r4Sq5Sq6SSSSSSS.r7SSSSS.r8 " S S\Rr                  5      r: " S S \Rr                  5      r; " S! S"\Rx                  5      r= " S# S$\>5      r? " S% S&\Rr                  5      r@\R                  " S'S(S)S*S+9  \R                  " S,S(S-S*S+9  \R                  " S.\
R                  " S/S05      S1S*S+9  \R                  " \:" S2S3S4S5S*S695        \R                  " \;" S70 S85      5        \R                  " \@" S9SS:S*S;95        \R                  " S<S*S=5        S> rES? rFS@ rGSA rHSB rISC rJ\R4                  (       a  \JrKOSD rKSE rLSF rMSG rN0 rOSH rPSI rQ0 rRSJ rSSK rTSL rUSM rVSN rWSO rXSP rYSQ rZSR r[SS r\ST r]\]r^SU r_\*4SV jr`SkSW jraSlSX jrbSY rcSZ rdS[ reS\ rfS*qg " S] S^\	R                  5      ri " S_ S`\	R                  5      rk " Sa Sb\	R                  5      rm " Sc Sd\	R                  " 5       5      roSe rpSf rqSg rrSmSh jrsS(qtSi ruSj rv\v" 5         g! \  a     GNf = f)na  Abseil Python logging module implemented on top of standard logging.

Simple usage:

    from absl import logging

    logging.info('Interesting Stuff')
    logging.info('Interesting Stuff with Arguments: %d', 42)

    logging.set_verbosity(logging.INFO)
    logging.log(logging.DEBUG, 'This will *not* be printed')
    logging.set_verbosity(logging.DEBUG)
    logging.log(logging.DEBUG, 'This will be printed')

    logging.warning('Worrying Stuff')
    logging.error('Alarming Stuff')
    logging.fatal('AAAAHHHHH!!!!')  # Process exits.

Usage note: Do not pre-format the strings in your program code.
Instead, let the logging module perform argument interpolation.
This saves cycles because strings that don't need to be printed
are never formatted.  Note that this module does not attempt to
interpolate arguments when no arguments are given.  In other words

    logging.info('Interesting Stuff: %s')

does not raise an exception because logging.info() has only one
argument, the message string.

"Lazy" evaluation for debugging:

If you do something like this:
    logging.debug('Thing: %s', thing.ExpensiveOp())
then the ExpensiveOp will be evaluated even if nothing
is printed to the log. To avoid this, use the level_debug() function:
  if logging.level_debug():
    logging.debug('Thing: %s', thing.ExpensiveOp())

Per file level logging is supported by logging.vlog() and
logging.vlog_is_on(). For example:

    if logging.vlog_is_on(2):
      logging.vlog(2, very_expensive_debug_message())

Notes on Unicode:

The log output is encoded as UTF-8.  Don't pass data in other encodings in
bytes() instances -- instead pass unicode string instances when you need to
(for both the format string and arguments).

Note on critical and fatal:
Standard logging module defines fatal as an alias to critical, but it's not
documented, and it does NOT actually terminate the program.
This module only defines fatal but not critical, and it DOES terminate the
program.

The differences in behavior are historical and unfortunate.
    )absolute_import)division)print_functionN)flags)abc)	converter)NoReturnz^(?P<severity>[IWEF])(?P<month>\d\d)(?P<day>\d\d) (?P<hour>\d\d):(?P<minute>\d\d):(?P<second>\d\d)\.(?P<microsecond>\d\d\d\d\d\d) +(?P<thread_id>-?\d+) (?P<filename>[a-zA-Z<][\w._<>-]+):(?P<line>\d+)   L      _absl_log_fatalzCRITICAL - loggingz	__init__.0123)debuginfowarningwarnerrorfatalr   r   r   r   )r   r   r   r   c                   f   ^  \ rS rSrSrU 4S jr\S 5       r\R                  S 5       rS r	Sr
U =r$ )_VerbosityFlag   zFlag class for -v/--verbosity.c                    > [         [        U ]
  " [        R                  " 5       [        R
                  " 5       /UQ70 UD6  g N)superr   __init__r   IntegerParserArgumentSerializerselfargskwargs	__class__s      0platform/bq/third_party/absl/logging/__init__.pyr    _VerbosityFlag.__init__   s>    	.$(  " 
     c                     U R                   $ r   _valuer$   s    r(   value_VerbosityFlag.value       ;;r*   c                 0    Xl         U R                  5         g r   )r-   _update_logging_levelsr$   vs     r(   r/   r0      s    K!r*   c                    [         (       d  gU R                  [        R                  ::  a!  [        R                  " U R                  5      nO [
        R                  U R                  S-
  -
  n[        [
        R                  R                  ;   aC  [         R                  [
        R                  5        [
        R                  R                  U5        g[         R                  U5        g)zRUpdates absl logging levels to the current verbosity.

Visibility: module-private
Nr   )_absl_loggerr-   r   
ABSL_DEBUGabsl_to_standardr   DEBUG_absl_handlerroothandlerssetLevelNOTSET)r$   standard_verbositys     r(   r3   %_VerbosityFlag._update_logging_levels   s    
 <{{i***$55dkkB #==DKK!O< --- GNN+ll././r*   r,   )__name__
__module____qualname____firstlineno____doc__r    propertyr/   setterr3   __static_attributes____classcell__r'   s   @r(   r   r      sA    &   	<<" "0 0r*   r   c                   f   ^  \ rS rSrSrU 4S jr\S 5       r\R                  S 5       rS r	Sr
U =r$ )_LoggerLevelsFlag   zFlag class for --logger_levels.c                 X   > [         [        U ]
  " [        5       [	        5       /UQ70 UD6  g r   )r   rM   r    _LoggerLevelsParser_LoggerLevelsSerializerr#   s      r(   r    _LoggerLevelsFlag.__init__   s3    	
T+! 
 r*   c                 6    U R                   R                  5       $ r   )r-   copyr.   s    r(   r/   _LoggerLevelsFlag.value   s     ;;r*   c                 <    Uc  0 OUU l         U R                  5         g r   )r-   _update_logger_levelsr4   s     r(   r/   rU      s    	"qDK r*   c                     U R                   R                  5        H*  u  p[        R                  " U5      R	                  U5        M,     g r   )r-   itemsr   	getLoggerr>   )r$   namelevels      r(   rW   '_LoggerLevelsFlag._update_logger_levels   s6     {{((*&&u- +r*   r,   )rB   rC   rD   rE   rF   r    rG   r/   rH   rW   rI   rJ   rK   s   @r(   rM   rM      sA    '   	<<! !. .r*   rM   c                       \ rS rSrSrS rSrg)rP      z Parser for --logger_levels flag.c                    [        U[        R                  5      (       a  U$ UR                  S5       Vs/ s H)  o"R	                  5       (       d  M  UR	                  5       PM+     nn[
        R                  " 5       nU H;  nUR                  SS5      u  pgUR	                  5       nUR	                  5       nXtU'   M=     U$ s  snf )N,:r   )
isinstancer   MappingsplitstripcollectionsOrderedDict)r$   r/   pairpairslevels
name_levelr[   r\   s           r(   parse_LoggerLevelsParser.parse   s    %%%l&+kk#&6G&6d**,\TZZ\&6EG $$&F
$$S!,kdZZ\dkkmeTl	 
 M Hs   B?B? N)rB   rC   rD   rE   rF   rm   rI   ro   r*   r(   rP   rP      s
    (r*   rP   c                       \ rS rSrSrS rSrg)rQ      z$Serializer for --logger_levels flag.c                     [        U[        R                  5      (       a  U$ SR                  S UR	                  5        5       5      $ )Nra   c              3   H   #    U  H  u  pS R                  X5      v   M     g7f)z{}:{}N)format).0r[   r\   s      r(   	<genexpr>4_LoggerLevelsSerializer.serialize.<locals>.<genexpr>  s"      F7Dt##}s    ")rc   sixstring_typesjoinrY   )r$   r/   s     r(   	serialize!_LoggerLevelsSerializer.serialize  sB    %))**l88 F7<{{}F F Fr*   ro   N)rB   rC   rD   rE   rF   r{   rI   ro   r*   r(   rQ   rQ      s    ,Fr*   rQ   c                   `   ^  \ rS rSrSrU 4S jr\S 5       r\R                  S 5       rSr	U =r
$ )_StderrthresholdFlagi
  z!Flag class for --stderrthreshold.c                    > [         [        U ]
  " [        R                  " 5       [        R
                  " 5       /UQ70 UD6  g r   )r   r~   r    r   ArgumentParserr"   r#   s      r(   r    _StderrthresholdFlag.__init__  s?    	
.  " 
 r*   c                     U R                   $ r   r,   r.   s    r(   r/   _StderrthresholdFlag.value  r1   r*   c                     U[         ;   a  [        U5      n[         U   nOQUR                  5       [        ;   a+  UR                  5       nUS:X  a  Sn[        [        U   5      nO[	        SU-  5      eXl        g )Nr   r   z--stderrthreshold must be one of (case-insensitive) 'debug', 'info', 'warning', 'error', 'fatal', or '0', '1', '2', '3', not '%s')_CPP_LEVEL_TO_NAMESintlower_CPP_NAME_TO_LEVELS
ValueErrorr-   )r$   r5   	cpp_values      r(   r/   r     sw     a&i
a
 a	
)	)
'')a	
f)!,-i,./01 1
 Kr*   r,   )rB   rC   rD   rE   rF   r    rG   r/   rH   rI   rJ   rK   s   @r(   r~   r~   
  s7    )   	<< r*   r~   logtostderrFzShould only log to stderr?T)allow_override_cppalsologtostderrzalso log to stderr?log_dirTEST_TMPDIR z directory to write logfiles into	verbosityzLogging verbosity level. Messages logged at this level or lower will be included. Set to 1 for debug logging. If the flag was not set or supplied, the value will be changed from the default of -1 (warning) to 0 (info) after flags are parsed.r5   )
short_nameallow_hide_cpplogger_levelszSpecify log level of loggers. The format is a CSV list of `name:level`. Where `name` is the logger name used with `logging.getLogger()`, and `level` is a level name  (INFO, DEBUG, etc). e.g. `myapp.foo:INFO,other.logger:DEBUG`stderrthresholdaM  log messages at this level, or more severe, to stderr in addition to the logfile.  Possible values are 'debug', 'info', 'warning', 'error', and 'fatal'.  Obsoletes --alsologtostderr. Using --alsologtostderr cancels the effect of this flag. Please also note that this flag is subject to --verbosity and requires logfile not be stderr.)r   showprefixforinfozIf False, do not prepend prefix to info messages when it's logged to stderr, --verbosity is set to INFO level, and python logging is used.c                  (    [         S   R                  $ )zReturns the logging verbosity.r   )FLAGSr/   ro   r*   r(   get_verbosityr   T  s    	{		!	!!r*   c                      [        U 5      nU[
        l        g! [         a$    [        R                  U R	                  5          n N9f = f)aa  Sets the logging verbosity.

Causes all messages of level <= v to be logged,
and all messages of level > v to be silently discarded.

Args:
  v: int|str, the verbosity level as an integer or string. Legal string values
      are those that can be coerced to an integer as well as case-insensitive
      'debug', 'info', 'warning', 'error', and 'fatal'.
N)r   r   r   
ABSL_NAMESupperr   r   )r5   	new_levels     r(   set_verbosityr   Y  s@    0AI %/ 
 0$$QWWY/I0s    +AAc                 2   U [         R                  ;   a  [         R                  U    [        l        g[	        U [
        5      (       a.  U R                  5       [         R                  ;   a  U [        l        g[        SR                  U [        U 5      5      5      e)a,  Sets the stderr threshold to the value passed in.

Args:
  s: str|int, valid strings values are case-insensitive 'debug',
      'info', 'warning', 'error', and 'fatal'; valid integer values are
      logging.DEBUG|INFO|WARNING|ERROR|FATAL.

Raises:
    ValueError: Raised when s is an invalid value.
zset_stderrthreshold only accepts integer absl logging level from -3 to 1, or case-insensitive string values 'debug', 'info', 'warning', 'error', and 'fatal'. But found "{}" ({}).N)r   ABSL_LEVELSr   r   rc   strr   r   r   rt   type)ss    r(   set_stderrthresholdr   k  sq     )

%11!4E!Saggi9+?+??E
	  &vaa1	3 3r*   c                 ,    [        [        U /UQ70 UD6  g)zLogs a fatal message.N)logFATALmsgr%   r&   s      r(   r   r     s     eS"4"6"r*   c                 ,    [        [        U /UQ70 UD6  g)zLogs an error message.N)r   ERRORr   s      r(   r   r         eS"4"6"r*   c                 ,    [        [        U /UQ70 UD6  g)zLogs a warning message.N)r   WARNINGr   s      r(   r   r     s    gs$T$V$r*   c                 d    [         R                  " S[        S5        [        [        U /UQ70 UD6  g)z"Deprecated, use 'warning' instead.z8The 'warn' function is deprecated, use 'warning' insteadr
   N)warningsr   DeprecationWarningr   r   r   s      r(   r   r     s*    MML$a)&t&v&r*   c                 ,    [        [        U /UQ70 UD6  g)zLogs an info message.N)r   INFOr   s      r(   r   r     s    dC!$!&!r*   c                 ,    [        [        U /UQ70 UD6  g)zLogs a debug message.N)r   r:   r   s      r(   r   r     r   r*   c                 "    [        U /UQ7SS06  g)z.Logs an exception, with traceback and message.exc_infoTN)r   )r   r%   s     r(   	exceptionr     s    "d"T"r*   c                 f    [        [        R                  U [        R                  " 5       5      5      $ )zWrapper for _log_counter_per_token. Thread-safe.

Args:
  token: The token for which to look up the count.

Returns:
  The number of times this function has been called with
  *token* as an argument (starting at 0).
)next_log_counter_per_token
setdefault	itertoolscount)tokens    r(   _get_next_log_count_per_tokenr     s$     
$//y7HI	JJr*   c                 n    [        [        5       R                  5       5      n[        XXB-  (       + /UQ76   g)a\  Logs 'msg % args' at level 'level' once per 'n' times.

Logs the 1st call, (N+1)st call, (2N+1)st call,  etc.
Not threadsafe.

Args:
  level: int, the absl logging level at which to log.
  msg: str, the message to be logged.
  n: int, the number of times this should be called before it is logged.
  *args: The args to be substituted into the msg.
Nr   get_absl_logger
findCallerlog_ifr\   r   nr%   r   s        r(   log_every_nr     s-     ((9(D(D(F
G%%)_,t,r*   c                     [         R                  " 5       n[        R                  U S5      nUb  X#-
  U:  a
  U[        U '   gg)a  Tests if 'num_seconds' have passed since 'token' was requested.

Not strictly thread-safe - may log with the wrong frequency if called
concurrently from multiple threads. Accuracy depends on resolution of
'timeit.default_timer()'.

Always returns True on the first call for a given 'token'.

Args:
  token: The token for which to look up the count.
  num_seconds: The number of seconds to test for.

Returns:
  Whether it has been >= 'num_seconds' since 'token' was last requested.
NTF)timeitdefault_timer_log_timer_per_tokenget)r   num_secondsnowthens       r(   _seconds_have_elapsedr     sC      	#		!	!%	.$	\cj[0"%r*   c                 b    [        [        5       R                  5       U5      n[        XU/UQ76   g)a  Logs 'msg % args' at level 'level' iff 'n_seconds' elapsed since last call.

Logs the first call, logs subsequent calls if 'n' seconds have elapsed since
the last logging call from the same call site (file + line). Not thread-safe.

Args:
  level: int, the absl logging level at which to log.
  msg: str, the message to be logged.
  n_seconds: float or int, seconds which should elapse before logging again.
  *args: The args to be substituted into the msg.
N)r   r   r   r   )r\   r   	n_secondsr%   
should_logs        r(   log_every_n_secondsr     s+     %_%6%A%A%CYO*Z'$'r*   c                 d    [        [        5       R                  5       5      n[        XXB:  /UQ76   g)a  Logs 'msg % args' at level 'level' only first 'n' times.

Not threadsafe.

Args:
  level: int, the absl logging level at which to log.
  msg: str, the message to be logged.
  n: int, the maximal number of times the message is logged.
  *args: The args to be substituted into the msg.
Nr   r   s        r(   log_first_nr     s+     ((9(D(D(F
G%UY&&r*   c                 ,    U(       a  [        X/UQ76   gg)zBLogs 'msg % args' at level 'level' only if condition is fulfilled.Nr   )r\   r   	conditionr%   s       r(   r   r     s    T r*   c                 j   U [         R                  :  a  [         R                  U S-
  -
  nO:U [         R                  :  a  [         R                  n [         R                  " U 5      n[
        R                  R                  (       d  [
        R                  " 5         [        R                  " XA/UQ70 UD6  g)a,  Logs 'msg % args' at absl logging level 'level'.

If no args are given just print msg, ignoring any interpolation specifiers.

Args:
  level: int, the absl logging level at which to log the message
      (logging.DEBUG|INFO|WARNING|ERROR|FATAL). While some C++ verbose logging
      level constants are also supported, callers should prefer explicit
      logging.vlog() calls for such purpose.

  msg: str, the message to be logged.
  *args: The args to be substituted into the msg.
  **kwargs: May contain exc_info to add exception traceback to message.
r   N)r   r8   STANDARD_DEBUG
ABSL_FATALr9   r   r<   r=   basicConfigr7   r   )r\   r   r%   r&   standard_levels        r(   r   r     s     Y!!! --;Ny###""e//6N
 
		>888r*   c                 "    [        X/UQ70 UD6  g)a  Log 'msg % args' at C++ vlog level 'level'.

Args:
  level: int, the C++ verbose logging level at which to log the message,
      e.g. 1, 2, 3, 4... While absl level constants are also supported,
      callers should prefer logging.log|debug|info|... calls for such purpose.
  msg: str, the message to be logged.
  *args: The args to be substituted into the msg.
  **kwargs: May contain exc_info to add exception traceback to message.
Nr   )r\   r   r%   r&   s       r(   vlogr   5  s     e"4"6"r*   c                     U [         R                  :  a  [         R                  U S-
  -
  nO:U [         R                  :  a  [         R                  n [         R                  " U 5      n[
        R                  U5      $ )ao  Checks if vlog is enabled for the given level in caller's source file.

Args:
  level: int, the C++ verbose logging level at which to log the message,
      e.g. 1, 2, 3, 4... While absl level constants are also supported,
      callers should prefer level_debug|level_info|... calls for
      checking those.

Returns:
  True if logging is turned on for that level.
r   )r   r8   r   r   r9   r7   isEnabledFor)r\   r   s     r(   
vlog_is_onr   C  sb     Y!!! --;Ny###""e//6N		"	">	22r*   c                  4    [        5       R                  5         gzFlushes all log files.N)get_absl_handlerflushro   r*   r(   r   r   \  s    r*   c                  $    [        5       [        :  $ )z+Returns True if debug logging is turned on.)r   r:   ro   r*   r(   level_debugr   a      	E	!!r*   c                  $    [        5       [        :  $ )z*Returns True if info logging is turned on.)r   r   ro   r*   r(   
level_infor   f  s    	D	  r*   c                  $    [        5       [        :  $ )z-Returns True if warning logging is turned on.)r   r   ro   r*   r(   level_warningr   k  s    	G	##r*   c                  $    [        5       [        :  $ )z+Returns True if error logging is turned on.)r   r   ro   r*   r(   level_errorr   s  r   r*   c                 &   U [         R                  ;  a  [        SR                  U 5      5      e[	        5       R
                  R                  nU[        R                  :X  d%  U[        R                  :X  d  [        US5      (       d  gUR                  $ )a4  Returns the name of the log file.

For Python logging, only one file is used and level is ignored. And it returns
empty string if it logs to stderr/stdout or the log stream has no `name`
attribute.

Args:
  level: int, the absl.logging level.

Raises:
  ValueError: Raised when `level` has an invalid value.
zInvalid absl.logging level {}r[   r   )r   r   r   rt   r   python_handlerstreamsysstderrstdouthasattrr[   )r\   r   s     r(   get_log_file_namer   x  sn     )'''
4;;EB
CC,,33&

f

2
&&
!
!;;r*   c                    U (       dU  [         R                  R                  [         R                  R                  [        R
                  S   5      5      S   n SU -  n [        US9n [        R                  " 5       n[        R                  " 5       nU < SU< SU< S3nX%U 4$ ! [         a:    [        [         S5      (       a   [        [         R                  " 5       5      n NfSn Njf = f)a  Computes the directory and filename prefix for log file.

Args:
  program_name: str|None, the filename part of the path to the program that
      is running without its extension.  e.g: if your program is called
      'usr/bin/foobar.py' this method should probably be called with
      program_name='foobar' However, this is just a convention, you can
      pass in any string you want, and it will be used as part of the
      log filename. If you don't pass in anything, the default behavior
      is as described in the example.  In python standard logging mode,
      the program_name will be prepended with py_ if it is the program_name
      argument is omitted.
  log_dir: str|None, the desired log directory.

Returns:
  (log_dir, file_prefix, symlink_prefix)

Raises:
  FileNotFoundError: raised in Python 3 when it cannot find a log directory.
  OSError: raised in Python 2 when it cannot find a log directory.
r   zpy_%s)r   getuidunknown.z.log)ospathsplitextbasenamer   argvfind_log_dirgetpassgetuserKeyErrorr   r   r   socketgethostname)program_namer   actual_log_dirusernamehostnamefile_prefixs         r(   find_log_dir_and_namesr    s    , 
 77##BGG$4$4SXXa[$AB1EL \)L0. H !(".(C+	l	22 
 r8RYY[!hhs   'B# #=C'"C'&C'c                    U (       a  U /nO1[         S   R                  (       a  [         S   R                  /nOSS/nU HW  n[        R                  R	                  U5      (       d  M)  [        R
                  " U[        R                  5      (       d  MU  Us  $    [        R                  (       a  [        O[        nU" SU-  5      e)a  Returns the most suitable directory to put log files into.

Args:
  log_dir: str|None, if specified, the logfile(s) will be created in that
      directory.  Otherwise if the --log_dir command-line flag is provided,
      the logfile will be created in that directory.  Otherwise the logfile
      will be created in a standard location.

Raises:
  FileNotFoundError: raised in Python 3 when it cannot find a log directory.
  OSError: raised in Python 2 when it cannot find a log directory.
r   z/tmp/z./z2Can't find a writable directory for logs, tried %s)r   r/   r   r   isdiraccessW_OKrx   PY2OSErrorFileNotFoundError)r   dirsdexception_classs       r(   r  r    s     9DY )""#DT?D a	ww}}QBIIa11h   #wwG,=/:TA	C Cr*   c                    [         R                  " U R                  5      n[        U R                  S-  S-  5      nSnU R                  n[        U 5      (       a  [        R                  n[        n[        R                  " U5      nSUUR                  UR                  UR                  UR                  UR                  U[!        5       U R"                  U R$                  U4-  $ )zrReturns the absl log prefix for the log record.

Args:
  record: logging.LogRecord, the record to get prefix for.
g      ?g    .Ar   z,%c%02d%02d %02d:%02d:%02d.%06d %5d %s:%d] %s)time	localtimecreatedr   levelno_is_non_absl_fatal_recordr   r   _CRITICAL_PREFIXr   get_initial_for_leveltm_montm_mdaytm_hourtm_mintm_sec_get_thread_idfilenamelineno)recordcreated_tuplecreated_microsecondcritical_prefixr\   severitys         r(   get_absl_log_prefixr.    s     ..0-FNNS0367/
..%v&& MME&O,,U3(	7oomm; 
 r*   c                 f   [        U 5      (       a@  [        U SS5      nUc  [        S5      eUR                  nUR                  nUR
                  nOJ[        U [        R                  5      (       a   [        5       R                  5       S   nU nSnO[        S5      e[        R                  X#U5        U $ )a  Skips reporting the prefix of a given function or name by ABSLLogger.

This is a convenience wrapper function / decorator for
`ABSLLogger.register_frame_to_skip`.

If a callable function is provided, only that function will be skipped.
If a function name is provided, all functions with the same name in the
file that this is called in will be skipped.

This can be used as a decorator of the intended function to be skipped.

Args:
  func: Callable function or its name as a string.

Returns:
  func (the input, unchanged).

Raises:
  ValueError: The input is callable but does not have a function code object.
  TypeError: The input is neither callable nor a string.
__code__Nz4Input callable does not have a function code object.r   z'Input is neither callable nor a string.)callablegetattrr   co_filenameco_nameco_firstlinenorc   rx   ry   r   r   	TypeError
ABSLLoggerregister_frame_to_skip)func	func_code	file_name	func_namefunc_linenos        r(   skip_log_prefixr>    s    , d^^j$/IMNN%%I!!I**K$(())!,,.q1IIK
=
>>##I+F	+r*   c                     U R                   [        R                  :  =(       a%    U R                  R	                  [
        S5      (       + $ NFr  r   r   __dict__r   _ABSL_LOG_FATAL
log_records    r(   r  r  (  s7    



- >!!%%ou=
=?r*   c                     U R                   [        R                  :  =(       a     U R                  R	                  [
        S5      $ r@  rA  rD  s    r(   _is_absl_fatal_recordrG  -  s4    



- :



!
!/5
9;r*   c                   n   ^  \ rS rSrSrSU 4S jjrSS jrSS jrS rU 4S jr	U 4S jr
U 4S	 jrS
rU =r$ )PythonHandleri6  z?The handler class used by Abseil Python logging implementation.c                 p   > [         [        U ]  U5        U R                  U=(       d
    [	        5       5        g r   )r   rI  r    setFormatterPythonFormatter)r$   r   	formatterr'   s      r(   r    PythonHandler.__init__9  s(    	-'/i4?#45r*   c           	         S[         l        [        XS9u  p4nSU[        R                  " S[        R
                  " [        R                  " 5       5      5      [        R                  " 5       4-  n[        R                  R                  X65      n[        R                  (       a  [        US5      U l        O[        USSS9U l        [        [        SS	5      (       a  [        R                  R                  X5S
-   5      n [        R                  R                  U5      (       a  [        R                   " U5        [        R"                  " [        R                  R%                  U5      U5        g	g	! [&         a     g	f = f)z;Starts logging messages to files instead of standard error.Fr	  r   z%s.INFO.%s.%dz%Y%m%d-%H%M%Sazutf-8)encodingsymlinkNz.INFO)r   r   r  r  strftimer  r   getpidr   rz   rx   r  openr   r2  islinkunlinkrS  r  EnvironmentError)	r$   r	  r   r
  r  symlink_prefixr  r'  rS  s	            r(   start_logging_to_file#PythonHandler.start_logging_to_file=  s   E2H!34/N ot~~diik'BC
		" H ww||N5H
ww3'dk39dk r9d##^g-EFg77>>'""
))G



277##H-w7 $   		s   >A.E. .
E;:E;c                 ~    [         S   R                  (       a  [        R                  U l        gU R                  XS9  g)z4Conditionally logs to files, based on --logtostderr.r   rP  N)r   r/   r   r   r   r[  r$   r	  r   s      r(   use_absl_log_filePythonHandler.use_absl_log_file]  s,    ]!!JJdk
  l Lr*   c                     U R                  5          U R                  R                  5         U R                  5         g! [        [        4 a     N#f = f! U R                  5         f = fr   )acquirer   r   rY  r   releaser.   s    r(   r   PythonHandler.flushd  sP    LLN
kk
 lln	 j) 
 llns!   = AA AA A%c                    > U R                   n[        R                  U l          [        [        U ]  U5        X l         g! X l         f = f)zEmits the record to stderr.

This temporarily sets the handler stream to stderr, calls
StreamHandler.emit, then reverts the stream back.

Args:
  record: logging.LogRecord, the record to log.
N)r   r   r   r   rI  emit)r$   r)  
old_streamr'   s      r(   _log_to_stderrPythonHandler._log_to_stderro  s8     J**DKM4%f-kJks	   > Ac                   > UR                   n[        R                  5       (       d>  [        (       a!  [        R
                  R                  S5        SqU R                  U5        O[        S   R                  (       a  U R                  U5        O[        [        U ]/  U5        [        R                  " [        S   R                  5      n[        S   R                  (       d  X#:  a/  U R                  [        R
                  :w  a  U R                  U5        [        U5      (       a&  U R!                  5         ["        R$                  " 5         gg)a<  Prints a record out to some streams.

If FLAGS.logtostderr is set, it will print to sys.stderr ONLY.
If FLAGS.alsologtostderr is set, it will print to sys.stderr.
If FLAGS.logtostderr is not set, it will log to the stream
  associated with the current thread.

Args:
  record: logging.LogRecord, the record to emit.
z5WARNING: Logging before flag parsing goes to stderr.
Fr   r   r   N)r  r   	is_parsed_warn_preinit_stderrr   r   writerh  r/   r   rI  rf  r   string_to_standardr   rG  r   r   abort)r$   r)  r\   stderr_thresholdr'   s       r(   rf  PythonHandler.emit  s    " NNE??		

D	F$
&!	}		#	#
&!M4%f-"55
!
"
(
(*"#))U-F
++
#F#V$$
jjl 	hhj %r*   c                   > U R                  5          U R                  5          [        R                  [        R                  [        R
                  [        R                  4nU R                  U;  aT  [        U R                  S5      (       a  U R                  R                  5       (       d  U R                  R                  5         [        [        U ]+  5         U R                  5         g! [         a     N/f = f! U R                  5         f = f)z*Closes the stream to which we are writing.isattyN)rb  r   r   r   r   
__stderr__
__stdout__r   r   rs  closer   r   rI  rc  )r$   user_managedr'   s     r(   rv  PythonHandler.close  s    LLN
jjl
 zz3::s~~s~~M;;l*X..dkk6H6H6J6J
++


 M4&(
lln  
 llns/   C9 B"C) C9 )
C63C9 5C66C9 9D)r   NN)rB   rC   rD   rE   rF   r    r[  r_  r   rh  rf  rv  rI   rJ   rK   s   @r(   rI  rI  6  s1    G6@M	$(T r*   rI  c                      ^  \ rS rSrSrU 4S jrS rS rS rS r	U 4S jr
S	 r\S
 5       rS rSS jrSS jrSrU =r$ )ABSLHandleri  z+Abseil Python logging module's log handler.c                 f   > [         [        U ]  5         [        US9U l        U R                  5         g )N)rM  )r   r{  r    rI  _python_handleractivate_python_handler)r$   python_logging_formatterr'   s     r(   r    ABSLHandler.__init__  s*    	+t%'(3KLD  "r*   c                 8    U R                   R                  U5      $ r   )_current_handlerrt   r$   r)  s     r(   rt   ABSLHandler.format  s      ''//r*   c                 :    U R                   R                  U5        g r   )r  rK  )r$   fmts     r(   rK  ABSLHandler.setFormatter  s    &&s+r*   c                 :    U R                   R                  U5        g r   )r  rf  r  s     r(   rf  ABSLHandler.emit  s    v&r*   c                 8    U R                   R                  5         g r   )r  r   r.   s    r(   r   ABSLHandler.flush  s    !r*   c                 ^   > [         [        U ]  5         U R                  R                  5         g r   )r   r{  rv  r  )r$   r'   s    r(   rv  ABSLHandler.close  s"    	+t"$!r*   c                 l    U R                  U5      nU(       a  U R                  R                  U5      $ U$ r   )filterr  handle)r$   r)  rvs      r(   r  ABSLHandler.handle  s/    	V	B	""))&11Ir*   c                     U R                   $ r   )r}  r.   s    r(   r   ABSLHandler.python_handler  s    r*   c                 &    U R                   U l        g)z?Uses the Python logging handler as the current logging handler.N)r}  r  r.   s    r(   r~  #ABSLHandler.activate_python_handler  s     00Dr*   c                 :    U R                   R                  X5        g r   )r  r_  r^  s      r(   r_  ABSLHandler.use_absl_log_file  s    ++LBr*   c                 :    U R                   R                  X5        g r   )r  r[  r^  s      r(   r[  !ABSLHandler.start_logging_to_file  s    //Fr*   )r  r}  ry  )rB   rC   rD   rE   rF   r    rt   rK  rf  r   rv  r  rG   r   r~  r_  r[  rI   rJ   rK   s   @r(   r{  r{    sT    3#0,'""    1CG Gr*   r{  c                   ,   ^  \ rS rSrSrU 4S jrSrU =r$ )rL  i  z&Formatter class used by PythonHandler.c                 Z  > [         S   R                  (       dr  [         S   R                  [        R                  :X  aM  UR                  [
        R                  :X  a/  [        R                  R                  [        R                  :X  a  SnO[        U5      nU[        [        U ]?  U5      -   $ )zAppends the message from the record to the results of the prefix.

Args:
  record: logging.LogRecord, the record to be formatted.

Returns:
  The formatted string representing the record.
r   r   r   )r   r/   r   	ABSL_INFOr  r   r   r;   r   r   r   r   r.  r   rL  rt   )r$   r)  prefixr'   s      r(   rt   PythonFormatter.format  s{     %&,,k  I$7$77',,&$$++szz9f"6*fE/47???r*   ro   )rB   rC   rD   rE   rF   rt   rI   rJ   rK   s   @r(   rL  rL    s    .@ @r*   rL  c                      ^  \ rS rSrSr\" 5       rSS jrS rS r	S r
S rS rS	 rS
 rU 4S jrS r\SS j5       rSrU =r$ )r7  i  a  A logger that will create LogRecords while skipping some stack frames.

This class maintains an internal list of filenames and method names
for use when determining who called the currently executing stack
frame.  Any method names from specific source files are skipped when
walking backwards through the stack.

Client code should use the register_frame_to_skip method to let the
ABSLLogger know which method from which file should be
excluded from the walk backwards through the stack.
c                    [         R                  n[        R                  " S5      nU(       Ga@  UR                  n[
        UR                  ;  Ga  UR                  UR                  UR                  4U;  a  UR                  UR                  4U;  a  [        R                  (       a*  U(       d#  UR                  UR                  UR                  4$ SnU(       aY  [        R                  " 5       nUR                  S5        [        R                   " XGS9  UR#                  5       R%                  S5      nUR                  UR                  UR                  U4$ UR&                  nU(       a  GM?  gg)a  Finds the frame of the calling method on the stack.

This method skips any frames registered with the
ABSLLogger and any methods from this file, and whatever
method is currently being used to generate the prefix for the log
line.  Then it returns the file name, line number, and method name
of the calling method.  An optional fourth item may be returned,
callers who only need things from the first three are advised to
always slice or index the result rather than using direct unpacking
assignment.

Args:
  stack_info: bool, when True, include the stack trace as a fourth item
      returned.  On Python 3 there are always four items returned - the
      fourth will be None when this is False.  On Python 2 the stdlib
      base class API only returns three items.  We do the same when this
      new parameter is unspecified or False for compatibility.

Returns:
  (filename, lineno, methodname[, sinfo]) of the calling method.
r
   NzStack (most recent call last):
)file
)r7  _frames_to_skipr   	_getframef_code_LOGGING_FILE_PREFIXr3  r4  r5  rx   r  f_linenoioStringIOrm  	tracebackprint_stackgetvaluerstripf_back)r$   
stack_info
stacklevel	f_to_skipframecodesinfoouts           r(   r   ABSLLogger.findCaller  s
   , **I MM!E
\\d
d&6&6
6T\\ '01T\\
*)
;77:""ENNDLLA
A%++-CII9:!!%2LLN))%0E""ENNDLL%H
Hlle! %r*   c                 N    U R                   " [        R                  U/UQ70 UD6  g)z+Logs 'msg % args' with severity 'CRITICAL'.N)r   r   CRITICALr$   r   r%   r&   s       r(   criticalABSLLogger.critical?  s     HHWs4T4V4r*   c                 N    U R                   " [        R                  U/UQ70 UD6  g)z(Logs 'msg % args' with severity 'FATAL'.N)r   r   r   r  s       r(   r   ABSLLogger.fatalC      HHW]]C1$1&1r*   c                 N    U R                   " [        R                  U/UQ70 UD6  g)z(Logs 'msg % args' with severity 'ERROR'.N)r   r   r   r  s       r(   r   ABSLLogger.errorG  r  r*   c                     [         R                  (       a  [        R                  " S[        S5        U R
                  " [        R                  U/UQ70 UD6  g)z'Logs 'msg % args' with severity 'WARN'.z6The 'warn' method is deprecated, use 'warning' insteadr
   N)rx   PY3r   r   r   r   r   WARNr  s       r(   r   ABSLLogger.warnK  s9    
wwmmL&+HHW\\3000r*   c                 N    U R                   " [        R                  U/UQ70 UD6  g)z*Logs 'msg % args' with severity 'WARNING'.N)r   r   r   r  s       r(   r   ABSLLogger.warningR  s    HHW__c3D3F3r*   c                 N    U R                   " [        R                  U/UQ70 UD6  g)z'Logs 'msg % args' with severity 'INFO'.N)r   r   r   r  s       r(   r   ABSLLogger.infoV  s    HHW\\3000r*   c                 N    U R                   " [        R                  U/UQ70 UD6  g)z(Logs 'msg % args' with severity 'DEBUG'.N)r   r   r:   r  s       r(   r   ABSLLogger.debugZ  r  r*   c                    > U[         R                  :  a  UR                  S0 5      nSU[        '   [        [
        U ]  " X/UQ70 UD6  g)aq  Logs a message at a cetain level substituting in the supplied arguments.

This method behaves differently in python and c++ modes.

Args:
  level: int, the standard logging level at which to log the message.
  msg: str, the text of the message to log.
  *args: The arguments to substitute in the message.
  **kwargs: The keyword arguments to substitute in the message.
extraTN)r   r   r   rC  r   r7  r   )r$   r\   r   r%   r&   r  r'   s         r(   r   ABSLLogger.log^  sH      ,e#eO	*d<T<V<r*   c                 T    U R                  U5      (       a  U R                  U5        gg)a  Calls handlers without checking Logger.disabled.

Non-root loggers are set to disabled after setup with logging.config if
it's not explicitly specified. Historically, absl logging will not be
disabled by that. To maintaining this behavior, this function skips
checking the Logger.disabled bit.

This logger can still be disabled by adding a filter that filters out
everything.

Args:
  record: logging.LogRecord, the record to handle.
N)r  callHandlersr  s     r(   r  ABSLLogger.handleq  s&     {{6
 r*   c                 ~    Ub  U R                   R                  XU45        gU R                   R                  X45        g)aH  Registers a function name to skip when walking the stack.

The ABSLLogger sometimes skips method calls on the stack
to make the log messages meaningful in their appropriate context.
This method registers a function from a particular file as one
which should be skipped.

Args:
  file_name: str, the name of the file that contains the function.
  function_name: str, the name of the function to skip.
  line_number: int, if provided, only the function with this starting line
      number will be skipped. Otherwise, all functions with the same name
      in the file will be skipped.
N)r  add)clsr;  function_nameline_numbers       r(   r8  !ABSLLogger.register_frame_to_skip  s:      	yEF	y89r*   ro   )Fr   r   )rB   rC   rD   rE   rF   setr  r   r  r   r   r   r   r   r   r   r  classmethodr8  rI   rJ   rK   s   @r(   r7  r7    sX    
 E/+Z5221412=& " : :r*   r7  c                  >    [         R                  " 5       n U [        -  $ )aO  Gets id of current thread, suitable for logging as an unsigned quantity.

If pywrapbase is linked, returns GetTID() for the thread ID to be
consistent with C++ logging.  Otherwise, returns the numeric thread id.
The quantities are made unsigned by masking with 2*sys.maxint + 1.

Returns:
  Thread ID unique to this process (unsigned)
)_thread_lib	get_ident_THREAD_ID_MASK)	thread_ids    r(   r&  r&    s     ##%)	_	$$r*   c                      [         $ )z!Returns the absl logger instance.)r7   ro   r*   r(   r   r     s    	r*   c                      [         $ )z"Returns the absl handler instance.)r;   ro   r*   r(   r   r     s    	r*   c                 Z    [        5       R                  5         U (       d  [        S5        gg)zuUses the python implementation of the logging code.

Args:
  quiet: No logging message about switching logging type.
zRestoring pure python loggingN)r   r~  r   )quiets    r(   use_python_loggingr    s$     ,,.		() 
r*   c                  :   [         (       d  [        R                  R                   V s/ s HF  n [	        U [        R
                  5      (       d  M$  U R                  [        R                  :X  d  MD  U PMH     nn U H"  n [        R                  R                  U 5        M$     Sq [        5       nU[        R                  R                  ;  aN  [        R                  R                  U5        [        S   R                  5         [        S   R                  5         ggs  sn f )zyUses the ABSL logging handler for logging.

This method is called in app.run() so the absl handler is used in absl apps.
Tr   r   N)+_attempted_to_remove_stderr_stream_handlersr   r<   r=   rc   StreamHandlerr   r   r   removeHandlerr   
addHandlerr   r3   rW   )hr=   absl_handlers      r(   use_absl_handlerr    s     
5	4 <<((L(aa../ 	
45HH

4J 	
(  L ll  # 26/!#,...LLL)	+--/	/002 /Ls   #DD/Dc                      [         (       a  g[        R                  " 5       n [        R                  " [        5        [        R
                  " S5      q [        R                  " U 5        [        5       n[        U5      qg)z!Initializes loggers and handlers.Nabsl)	r7   r   getLoggerClasssetLoggerClassr7  rZ   rL  r{  r;   )original_logger_classr  s     r(   _initializer    s\     \
!002	$""6*,	./,.67-r*   ry  r   )F)wrF   
__future__r   r   r   rg   r  r  r   r   r   r  structr   r  r   r  typesr   r  r   absl._collections_abcr   absl.loggingr   rx   r  threadr  	threadingtypingr	   ImportErrorr   r   r   
ABSL_ERRORr   ABSL_WARNINGr   r  r  r   r8   r:   ABSL_LOGGING_PREFIX_REGEXcalcsizer  rC  r  r   rz   r  r7   r;   r   r   Flagr   rM   r   rP   objectrQ   r~   DEFINE_booleanDEFINE_stringgetenvDEFINE_flagr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   
level_warnr   r   r  r  r.  r>  r  rG  rl  r  rI  Handlerr{  	FormatterrL  r  r7  r&  r   r   r  r  r  r  ro   r*   r(   <module>r     s  9v '  %   	   	   
       % " 
77!
 	 	

 
 7  ,q01A5 $ !  ww||I{;     
				 '0UZZ '0T.

 .:%.. &Ff F5:: D   ]1dL   &*tE   IIImR06'+-   .' 4) *   	9:;   &w &*+ ,   ($34"
$3.##
%
 77	$'"
#
#  K-&  2( '9D#32
"
!
$
 
"
 ! ..3bCB@$N?
;  GG)) GT+G'// +G\@g'' @,Q:'') Q:h%

* /4 +328  }#  s   >L* *L43L4