def emit(self, record):
        """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.
    """
        # People occasionally call logging functions at import time before
        # our flags may have even been defined yet, let alone even parsed, as we
        # rely on the C++ side to define some flags for us and app init to
        # deal with parsing.  Match the C++ library behavior of notify and emit
        # such messages to stderr.  It encourages people to clean-up and does
        # not hide the message.
        level = record.levelno
        if not FLAGS.is_parsed(
        ):  # Also implies "before flag has been defined".
            global _warn_preinit_stderr
            if _warn_preinit_stderr:
                sys.stderr.write(
                    'WARNING: Logging before flag parsing goes to stderr.\n')
                _warn_preinit_stderr = False
            self._log_to_stderr(record)
        elif FLAGS['logtostderr'].value:
            self._log_to_stderr(record)
        else:
            super(PythonHandler, self).emit(record)
            stderr_threshold = converter.string_to_standard(
                FLAGS['stderrthreshold'].value)
            if ((FLAGS['alsologtostderr'].value or level >= stderr_threshold)
                    and self.stream != sys.stderr):
                self._log_to_stderr(record)
        # Die when the record is created from ABSLLogger and level is FATAL.
        if _is_absl_fatal_record(record):
            self.flush()  # Flush the log before dying.

            # In threaded python, sys.exit() from a non-main thread only
            # exits the thread in question.
            os.abort()
  def emit(self, record):
    """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.
    """
    # People occasionally call logging functions at import time before
    # our flags may have even been defined yet, let alone even parsed, as we
    # rely on the C++ side to define some flags for us and app init to
    # deal with parsing.  Match the C++ library behavior of notify and emit
    # such messages to stderr.  It encourages people to clean-up and does
    # not hide the message.
    level = record.levelno
    if not FLAGS.is_parsed():  # Also implies "before flag has been defined".
      global _warn_preinit_stderr
      if _warn_preinit_stderr:
        sys.stderr.write(
            'WARNING: Logging before flag parsing goes to stderr.\n')
        _warn_preinit_stderr = False
      self._log_to_stderr(record)
    elif FLAGS['logtostderr'].value:
      self._log_to_stderr(record)
    else:
      super(PythonHandler, self).emit(record)
      stderr_threshold = converter.string_to_standard(
          FLAGS['stderrthreshold'].value)
      if ((FLAGS['alsologtostderr'].value or level >= stderr_threshold) and
          self.stream != sys.stderr):
        self._log_to_stderr(record)
    # Die when the record is created from ABSLLogger and level is FATAL.
    if _is_absl_fatal_record(record):
      self.flush()  # Flush the log before dying.

      # In threaded python, sys.exit() from a non-main thread only
      # exits the thread in question.
      os.abort()
    def test_string_to_standard(self):
        self.assertEqual(logging.DEBUG, converter.string_to_standard('debug'))
        self.assertEqual(logging.INFO, converter.string_to_standard('info'))
        self.assertEqual(logging.WARNING, converter.string_to_standard('warn'))
        self.assertEqual(logging.WARNING,
                         converter.string_to_standard('warning'))
        self.assertEqual(logging.ERROR, converter.string_to_standard('error'))
        self.assertEqual(logging.CRITICAL,
                         converter.string_to_standard('fatal'))

        self.assertEqual(logging.DEBUG, converter.string_to_standard('DEBUG'))
        self.assertEqual(logging.INFO, converter.string_to_standard('INFO'))
        self.assertEqual(logging.WARNING, converter.string_to_standard('WARN'))
        self.assertEqual(logging.WARNING,
                         converter.string_to_standard('WARNING'))
        self.assertEqual(logging.ERROR, converter.string_to_standard('ERROR'))
        self.assertEqual(logging.CRITICAL,
                         converter.string_to_standard('FATAL'))