Python logging.FATAL Examples

The following are 30 code examples of logging.FATAL(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module logging , or try the search function .
Example #1
Source File: test_logging.py    From Fluid-Designer with GNU General Public License v3.0 6 votes vote down vote up
def test_nested_with_virtual_parent(self):
        # Logging levels when some parent does not exist yet.
        m = self.next_message

        INF = logging.getLogger("INF")
        GRANDCHILD = logging.getLogger("INF.BADPARENT.UNDEF")
        CHILD = logging.getLogger("INF.BADPARENT")
        INF.setLevel(logging.INFO)

        # These should log.
        GRANDCHILD.log(logging.FATAL, m())
        GRANDCHILD.info(m())
        CHILD.log(logging.FATAL, m())
        CHILD.info(m())

        # These should not log.
        GRANDCHILD.debug(m())
        CHILD.debug(m())

        self.assert_log_lines([
            ('INF.BADPARENT.UNDEF', 'CRITICAL', '1'),
            ('INF.BADPARENT.UNDEF', 'INFO', '2'),
            ('INF.BADPARENT', 'CRITICAL', '3'),
            ('INF.BADPARENT', 'INFO', '4'),
        ]) 
Example #2
Source File: test_logging.py    From gcblue with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def test_nested_with_virtual_parent(self):
        # Logging levels when some parent does not exist yet.
        m = self.next_message

        INF = logging.getLogger("INF")
        GRANDCHILD = logging.getLogger("INF.BADPARENT.UNDEF")
        CHILD = logging.getLogger("INF.BADPARENT")
        INF.setLevel(logging.INFO)

        # These should log.
        GRANDCHILD.log(logging.FATAL, m())
        GRANDCHILD.info(m())
        CHILD.log(logging.FATAL, m())
        CHILD.info(m())

        # These should not log.
        GRANDCHILD.debug(m())
        CHILD.debug(m())

        self.assert_log_lines([
            ('INF.BADPARENT.UNDEF', 'CRITICAL', '1'),
            ('INF.BADPARENT.UNDEF', 'INFO', '2'),
            ('INF.BADPARENT', 'CRITICAL', '3'),
            ('INF.BADPARENT', 'INFO', '4'),
        ]) 
Example #3
Source File: plugin.py    From pytest-logger with MIT License 6 votes vote down vote up
def _late_addoptions(parser, logcfg):
    """Add options to control logger"""
    parser.addini(
        name='logger_logsdir',
        help='base directory with log files for file loggers [basetemp]',
        default=None,
    )
    group = parser.getgroup('logger')
    group.addoption('--logger-logsdir',
                    help='pick you own logs directory instead of default '
                         'directory under session tmpdir')

    if logcfg._enabled:
        parser = _log_option_parser(logcfg._loggers)
        group.addoption('--loggers',
                        default=parser(logcfg._log_option_default),
                        type=parser,
                        metavar='LOGGER,LOGGER.LEVEL,...',
                        help='comma delimited list of loggers optionally suffixed with level '
                             'preceded by a dot. Levels can be lower or uppercase, or numeric. '
                             'For example: "logger1,logger2.info,logger3.FATAL,logger4.25"') 
Example #4
Source File: test_logging.py    From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 6 votes vote down vote up
def test_nested_with_virtual_parent(self):
        # Logging levels when some parent does not exist yet.
        m = self.next_message

        INF = logging.getLogger("INF")
        GRANDCHILD = logging.getLogger("INF.BADPARENT.UNDEF")
        CHILD = logging.getLogger("INF.BADPARENT")
        INF.setLevel(logging.INFO)

        # These should log.
        GRANDCHILD.log(logging.FATAL, m())
        GRANDCHILD.info(m())
        CHILD.log(logging.FATAL, m())
        CHILD.info(m())

        # These should not log.
        GRANDCHILD.debug(m())
        CHILD.debug(m())

        self.assert_log_lines([
            ('INF.BADPARENT.UNDEF', 'CRITICAL', '1'),
            ('INF.BADPARENT.UNDEF', 'INFO', '2'),
            ('INF.BADPARENT', 'CRITICAL', '3'),
            ('INF.BADPARENT', 'INFO', '4'),
        ]) 
Example #5
Source File: test_logging.py    From CTFCrackTools-V2 with GNU General Public License v3.0 6 votes vote down vote up
def test_nested_with_virtual_parent(self):
        # Logging levels when some parent does not exist yet.
        m = self.next_message

        INF = logging.getLogger("INF")
        GRANDCHILD = logging.getLogger("INF.BADPARENT.UNDEF")
        CHILD = logging.getLogger("INF.BADPARENT")
        INF.setLevel(logging.INFO)

        # These should log.
        GRANDCHILD.log(logging.FATAL, m())
        GRANDCHILD.info(m())
        CHILD.log(logging.FATAL, m())
        CHILD.info(m())

        # These should not log.
        GRANDCHILD.debug(m())
        CHILD.debug(m())

        self.assert_log_lines([
            ('INF.BADPARENT.UNDEF', 'CRITICAL', '1'),
            ('INF.BADPARENT.UNDEF', 'INFO', '2'),
            ('INF.BADPARENT', 'CRITICAL', '3'),
            ('INF.BADPARENT', 'INFO', '4'),
        ]) 
Example #6
Source File: STARROrderMedConversion.py    From CDSS with GNU General Public License v3.0 6 votes vote down vote up
def main(self, argv):
        """Main method, callable from command line"""
        log.setLevel(logging.FATAL)

        usage_str = "usage: %prog [options]\n"
        parser = OptionParser(usage=usage_str)
        parser.add_option("-s", "--startDate", dest="startDate", metavar="<startDate>",  help="Date string (e.g., 2011-12-15), if provided, will only run conversion on items with ordering time on or after this date.")
        parser.add_option("-e", "--endDate", dest="endDate", metavar="<endDate>",  help="Date string (e.g., 2011-12-15), if provided, will only run conversion on items with ordering time before this date.")
        parser.add_option("-n", "--normalizeMixtures", dest="normalizeMixtures", action="store_true",  help="If set, when find medication mixtures, will unravel / normalize into separate entries, one for each ingredient")
        parser.add_option("-d", "--doseCountLimit", dest="doseCountLimit", help="Medication orders with a finite number of doses specified less than this limit will be labeled as different items than those without a number specified, or whose number is >= to this limit. Intended to distinguish things like IV single bolus / use vs. continuous infusions and standing medication orders")
        (options, args) = parser.parse_args(argv[1:])

        log.info("Starting: " + str.join(" ", argv))
        timer = time.time()

        conv_options = ConversionOptions()
        conv_options.extract_parser_options(options)

        self.convertAndUpload(conv_options)

        timer = time.time() - timer
        log.info("%.3f seconds to complete", timer) 
Example #7
Source File: im.py    From scaleio-py with Apache License 2.0 6 votes vote down vote up
def _get_log_level(level):
        """
        small static method to get logging level
        :param str level: string of the level e.g. "INFO"
        :returns logging.<LEVEL>: appropriate debug level
        """
        # default to DEBUG
        if level is None or level == "DEBUG":
            return logging.DEBUG

        level = level.upper()
        # Make debugging configurable
        if level == "INFO":
            return logging.INFO
        elif level == "WARNING":
            return logging.WARNING
        elif level == "CRITICAL":
            return logging.CRITICAL
        elif level == "ERROR":
            return logging.ERROR
        elif level == "FATAL":
            return logging.FATAL
        else:
            raise Exception("UnknownLogLevelException: enter a valid log level") 
Example #8
Source File: client.py    From insights-core with Apache License 2.0 6 votes vote down vote up
def get_console_handler(config):
    if config.silent:
        target_level = logging.FATAL
    elif config.verbose:
        target_level = logging.DEBUG
    elif config.net_debug:
        target_level = NETWORK
    elif config.quiet:
        target_level = logging.ERROR
    else:
        target_level = logging.INFO

    handler = logging.StreamHandler(sys.stdout)
    handler.setLevel(target_level)

    log_format = LOG_FORMAT if config.verbose else "%(message)s"
    handler.setFormatter(logging.Formatter(log_format))

    return handler 
Example #9
Source File: test_logging.py    From ironpython3 with Apache License 2.0 6 votes vote down vote up
def test_nested_with_virtual_parent(self):
        # Logging levels when some parent does not exist yet.
        m = self.next_message

        INF = logging.getLogger("INF")
        GRANDCHILD = logging.getLogger("INF.BADPARENT.UNDEF")
        CHILD = logging.getLogger("INF.BADPARENT")
        INF.setLevel(logging.INFO)

        # These should log.
        GRANDCHILD.log(logging.FATAL, m())
        GRANDCHILD.info(m())
        CHILD.log(logging.FATAL, m())
        CHILD.info(m())

        # These should not log.
        GRANDCHILD.debug(m())
        CHILD.debug(m())

        self.assert_log_lines([
            ('INF.BADPARENT.UNDEF', 'CRITICAL', '1'),
            ('INF.BADPARENT.UNDEF', 'INFO', '2'),
            ('INF.BADPARENT', 'CRITICAL', '3'),
            ('INF.BADPARENT', 'INFO', '4'),
        ]) 
Example #10
Source File: __init__.py    From abseil-py with Apache License 2.0 6 votes vote down vote up
def log(self, level, msg, *args, **kwargs):
    """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.
    """
    if level >= logging.FATAL:
      # Add property to the LogRecord created by this logger.
      # This will be used by the ABSLHandler to determine whether it should
      # treat CRITICAL/FATAL logs as really FATAL.
      extra = kwargs.setdefault('extra', {})
      extra[_ABSL_LOG_FATAL] = True
    super(ABSLLogger, self).log(level, msg, *args, **kwargs) 
Example #11
Source File: log.py    From ARK with MIT License 6 votes vote down vote up
def fatal(self, text, *args):
        """
        打印fatal日志

        :param obj text: 要输出的文本信息,通过python字符串的%语法可以获得类似c语言printf的效果
        :param args: 格式化字符串中占位符对应的变量值,如果变量是对象则打印成json
        :returns: 无返回
        :rtype: None
        """
        logger = logging.getLogger(self._log_name)
        texts, json_args = self._format_request(logger.getEffectiveLevel(), text, args)
        if sys.exc_info()[0] is None:
            ei = None
        else:
            ei = True
        if len(json_args) > 0:
            logger.log(logging.FATAL, texts, *json_args, exc_info=ei)
        else:
            logger.log(logging.FATAL, texts, exc_info=ei) 
Example #12
Source File: log.py    From ARK with MIT License 6 votes vote down vote up
def tlog(self, level, text, *args):
        """
        记录文本日志信息,较高级别的日志(FATAL)会被收集到总控统一存储以备后续追查。
        实际的文本日志组装和输出是由标准库\
         `logging — Logging facility for Python <https://docs.python.org/2.7/library/logging.html>`_\ 提供的

        :param int level: 日志级别,级别包括:DEBUG < INFO < WARNING < ERROR < CRITICAL
        :param obj text: 要输出的文本信息,通过python字符串的%语法可以获得类似c语言printf的效果
        :param args: 格式化字符串中占位符对应的变量值,如果变量是对象则打印成json
        :returns: 无返回
        :rtype: None
        """
        logger = logging.getLogger(self._log_name)
        texts, json_args = self._format_request(logger.getEffectiveLevel(), text, args)
        if len(json_args) > 0:
            logger.log(level, texts, *json_args)
        else:
            logger.log(level, texts) 
Example #13
Source File: test_logging.py    From oss-ftp with MIT License 6 votes vote down vote up
def test_nested_with_virtual_parent(self):
        # Logging levels when some parent does not exist yet.
        m = self.next_message

        INF = logging.getLogger("INF")
        GRANDCHILD = logging.getLogger("INF.BADPARENT.UNDEF")
        CHILD = logging.getLogger("INF.BADPARENT")
        INF.setLevel(logging.INFO)

        # These should log.
        GRANDCHILD.log(logging.FATAL, m())
        GRANDCHILD.info(m())
        CHILD.log(logging.FATAL, m())
        CHILD.info(m())

        # These should not log.
        GRANDCHILD.debug(m())
        CHILD.debug(m())

        self.assert_log_lines([
            ('INF.BADPARENT.UNDEF', 'CRITICAL', '1'),
            ('INF.BADPARENT.UNDEF', 'INFO', '2'),
            ('INF.BADPARENT', 'CRITICAL', '3'),
            ('INF.BADPARENT', 'INFO', '4'),
        ]) 
Example #14
Source File: test_logger.py    From pyexperiment with MIT License 6 votes vote down vote up
def test_print_timings_prints(self):
        """Test timing code and printing really prints a message
        """
        buf = io.StringIO()

        # Nothing should be logged yet
        self.assertEqual(len(self.log_stream.getvalue()), 0)

        log.initialize()
        # Still, nothing should be logged yet
        self.assertEqual(len(self.log_stream.getvalue()), 0)

        with log.timed(level=logging.FATAL):
            _ = 1 + 1

        with stdout_redirector(buf):
            log.print_timings()

        # Something should be printed
        self.assertNotEqual(len(buf.getvalue()), 0)

        log.close()
        # Something should be logged
        self.assertNotEqual(len(self.log_stream.getvalue()), 0) 
Example #15
Source File: test_logging.py    From BinderFilter with MIT License 6 votes vote down vote up
def test_nested_with_virtual_parent(self):
        # Logging levels when some parent does not exist yet.
        m = self.next_message

        INF = logging.getLogger("INF")
        GRANDCHILD = logging.getLogger("INF.BADPARENT.UNDEF")
        CHILD = logging.getLogger("INF.BADPARENT")
        INF.setLevel(logging.INFO)

        # These should log.
        GRANDCHILD.log(logging.FATAL, m())
        GRANDCHILD.info(m())
        CHILD.log(logging.FATAL, m())
        CHILD.info(m())

        # These should not log.
        GRANDCHILD.debug(m())
        CHILD.debug(m())

        self.assert_log_lines([
            ('INF.BADPARENT.UNDEF', 'CRITICAL', '1'),
            ('INF.BADPARENT.UNDEF', 'INFO', '2'),
            ('INF.BADPARENT', 'CRITICAL', '3'),
            ('INF.BADPARENT', 'INFO', '4'),
        ]) 
Example #16
Source File: test_logging.py    From ironpython2 with Apache License 2.0 6 votes vote down vote up
def test_nested_with_virtual_parent(self):
        # Logging levels when some parent does not exist yet.
        m = self.next_message

        INF = logging.getLogger("INF")
        GRANDCHILD = logging.getLogger("INF.BADPARENT.UNDEF")
        CHILD = logging.getLogger("INF.BADPARENT")
        INF.setLevel(logging.INFO)

        # These should log.
        GRANDCHILD.log(logging.FATAL, m())
        GRANDCHILD.info(m())
        CHILD.log(logging.FATAL, m())
        CHILD.info(m())

        # These should not log.
        GRANDCHILD.debug(m())
        CHILD.debug(m())

        self.assert_log_lines([
            ('INF.BADPARENT.UNDEF', 'CRITICAL', '1'),
            ('INF.BADPARENT.UNDEF', 'INFO', '2'),
            ('INF.BADPARENT', 'CRITICAL', '3'),
            ('INF.BADPARENT', 'INFO', '4'),
        ]) 
Example #17
Source File: logging.py    From kopf with MIT License 6 votes vote down vote up
def emit(self, record: logging.LogRecord) -> None:
        # Same try-except as in e.g. `logging.StreamHandler`.
        try:
            ref = getattr(record, 'k8s_ref')
            type = (
                "Debug" if record.levelno <= logging.DEBUG else
                "Normal" if record.levelno <= logging.INFO else
                "Warning" if record.levelno <= logging.WARNING else
                "Error" if record.levelno <= logging.ERROR else
                "Fatal" if record.levelno <= logging.FATAL else
                logging.getLevelName(record.levelno).capitalize())
            reason = 'Logging'
            message = self.format(record)
            posting.enqueue(
                ref=ref,
                type=type,
                reason=reason,
                message=message)
        except Exception:
            self.handleError(record) 
Example #18
Source File: __init__.py    From abseil-py with Apache License 2.0 6 votes vote down vote up
def set_stderrthreshold(s):
  """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.
  """
  if s in converter.ABSL_LEVELS:
    FLAGS.stderrthreshold = converter.ABSL_LEVELS[s]
  elif isinstance(s, str) and s.upper() in converter.ABSL_NAMES:
    FLAGS.stderrthreshold = s
  else:
    raise ValueError(
        'set_stderrthreshold only accepts integer absl logging level '
        'from -3 to 1, or case-insensitive string values '
        "'debug', 'info', 'warning', 'error', and 'fatal'. "
        'But found "{}" ({}).'.format(s, type(s))) 
Example #19
Source File: _common.py    From ungoogled-chromium with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def __call__(self, parser, namespace, value, option_string=None):
        if option_string in ('--verbose', '-v'):
            value = logging.DEBUG
        elif option_string in ('--quiet', '-q'):
            value = logging.ERROR
        else:
            levels = {
                'FATAL': logging.FATAL,
                'ERROR': logging.ERROR,
                'WARNING': logging.WARNING,
                'INFO': logging.INFO,
                'DEBUG': logging.DEBUG
            }
            value = levels[value]
        set_logging_level(value)


# Public methods 
Example #20
Source File: test_logging.py    From CTFCrackTools with GNU General Public License v3.0 6 votes vote down vote up
def test_nested_with_virtual_parent(self):
        # Logging levels when some parent does not exist yet.
        m = self.next_message

        INF = logging.getLogger("INF")
        GRANDCHILD = logging.getLogger("INF.BADPARENT.UNDEF")
        CHILD = logging.getLogger("INF.BADPARENT")
        INF.setLevel(logging.INFO)

        # These should log.
        GRANDCHILD.log(logging.FATAL, m())
        GRANDCHILD.info(m())
        CHILD.log(logging.FATAL, m())
        CHILD.info(m())

        # These should not log.
        GRANDCHILD.debug(m())
        CHILD.debug(m())

        self.assert_log_lines([
            ('INF.BADPARENT.UNDEF', 'CRITICAL', '1'),
            ('INF.BADPARENT.UNDEF', 'INFO', '2'),
            ('INF.BADPARENT', 'CRITICAL', '3'),
            ('INF.BADPARENT', 'INFO', '4'),
        ]) 
Example #21
Source File: converter_test.py    From abseil-py with Apache License 2.0 6 votes vote down vote up
def test_standard_to_absl(self):
    self.assertEqual(
        absl_logging.DEBUG, converter.standard_to_absl(logging.DEBUG))
    self.assertEqual(
        absl_logging.INFO, converter.standard_to_absl(logging.INFO))
    self.assertEqual(
        absl_logging.WARN, converter.standard_to_absl(logging.WARN))
    self.assertEqual(
        absl_logging.WARN, converter.standard_to_absl(logging.WARNING))
    self.assertEqual(
        absl_logging.ERROR, converter.standard_to_absl(logging.ERROR))
    self.assertEqual(
        absl_logging.FATAL, converter.standard_to_absl(logging.FATAL))
    self.assertEqual(
        absl_logging.FATAL, converter.standard_to_absl(logging.CRITICAL))
    # vlog levels.
    self.assertEqual(2, converter.standard_to_absl(logging.DEBUG - 1))
    self.assertEqual(3, converter.standard_to_absl(logging.DEBUG - 2))

    with self.assertRaises(TypeError):
      converter.standard_to_absl('') 
Example #22
Source File: logger.py    From anchore-engine with Apache License 2.0 5 votes vote down vote up
def fatal(msg_string):
    return _msg(msg_string, msg_log_level='FATAL') 
Example #23
Source File: test_units.py    From pytest-logger with MIT License 5 votes vote down vote up
def test_loggers_from_logcfg():
    logcfg = plugin.LoggerConfig()
    logcfg.add_loggers(['a', 'b', 'c'], stdout_level=logging.ERROR, file_level='warn')
    logcfg.add_loggers(['d'], stdout_level='10')

    log_option = [('b', logging.FATAL), 'd']

    loggers = plugin._loggers_from_logcfg(logcfg, log_option)
    assert loggers.stdout == [('b', logging.FATAL), ('d', 10)]
    assert loggers.file == [('a', logging.WARN), ('b', logging.WARN), ('c', logging.WARN), ('d', 0)]
    assert loggers 
Example #24
Source File: converter_test.py    From abseil-py with Apache License 2.0 5 votes vote down vote up
def test_absl_to_cpp(self):
    self.assertEqual(0, converter.absl_to_cpp(absl_logging.DEBUG))
    self.assertEqual(0, converter.absl_to_cpp(absl_logging.INFO))
    self.assertEqual(1, converter.absl_to_cpp(absl_logging.WARN))
    self.assertEqual(2, converter.absl_to_cpp(absl_logging.ERROR))
    self.assertEqual(3, converter.absl_to_cpp(absl_logging.FATAL))

    with self.assertRaises(TypeError):
      converter.absl_to_cpp('') 
Example #25
Source File: test_units.py    From pytest-logger with MIT License 5 votes vote down vote up
def test_sanitize_level():
    assert plugin._sanitize_level(logging.INFO) == logging.INFO
    assert plugin._sanitize_level('15') == 15
    assert plugin._sanitize_level('warn') == logging.WARN
    assert plugin._sanitize_level('FATAL') == logging.FATAL

    with pytest.raises(TypeError):
        plugin._sanitize_level('WARN ')
    with pytest.raises(TypeError):
        plugin._sanitize_level('unknown')
    with pytest.raises(TypeError):
        plugin._sanitize_level(1.0)

    assert plugin._sanitize_level('WARN ', raises=False) is None 
Example #26
Source File: test_sslproto.py    From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 5 votes vote down vote up
def test_fatal_error_no_name_error(self):
        # From issue #363.
        # _fatal_error() generates a NameError if sslproto.py
        # does not import base_events.
        waiter = asyncio.Future(loop=self.loop)
        ssl_proto = self.ssl_protocol(waiter)
        # Temporarily turn off error logging so as not to spoil test output.
        log_level = log.logger.getEffectiveLevel()
        log.logger.setLevel(logging.FATAL)
        try:
            ssl_proto._fatal_error(None)
        finally:
            # Restore error logging.
            log.logger.setLevel(log_level) 
Example #27
Source File: utils.py    From pylot with Apache License 2.0 5 votes vote down vote up
def set_tf_loglevel(level):
    """To be used to suppress TensorFlow logging."""
    import logging
    import os
    if level >= logging.FATAL:
        os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
    if level >= logging.ERROR:
        os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
    if level >= logging.WARNING:
        os.environ['TF_CPP_MIN_LOG_LEVEL'] = '1'
    else:
        os.environ['TF_CPP_MIN_LOG_LEVEL'] = '0'
    logging.getLogger('tensorflow').setLevel(level) 
Example #28
Source File: converter_test.py    From abseil-py with Apache License 2.0 5 votes vote down vote up
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')) 
Example #29
Source File: converter_test.py    From abseil-py with Apache License 2.0 5 votes vote down vote up
def test_standard_to_cpp(self):
    self.assertEqual(0, converter.standard_to_cpp(logging.DEBUG))
    self.assertEqual(0, converter.standard_to_cpp(logging.INFO))
    self.assertEqual(1, converter.standard_to_cpp(logging.WARN))
    self.assertEqual(1, converter.standard_to_cpp(logging.WARNING))
    self.assertEqual(2, converter.standard_to_cpp(logging.ERROR))
    self.assertEqual(3, converter.standard_to_cpp(logging.FATAL))
    self.assertEqual(3, converter.standard_to_cpp(logging.CRITICAL))

    with self.assertRaises(TypeError):
      converter.standard_to_cpp('') 
Example #30
Source File: sfdc.py    From SalesforcePy with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def __init__(self, *args, **kwargs):
        """ Constructor.

            :Parameters:
                - `*username` (`string`) - Salesforce username.
                - `*password` (`string`) - Salesforce password.
                - `*login_url` (`string`) - Salesforce login URL.
                - `*client_id` (`string`) - Salesforce client ID.
                - `*client_secret` (`string`) - Salesforce client secret.
                - `\**kwargs` - kwargs (see below)

            :Keyword Arguments:
                * *protocol* (`string`) --
                    Protocol (future use)
                * *proxies* (`dict`) --
                    A dict containing proxies to be used by `requests` module. Ex:
                        `{"https": "example.org:443"}`
                    Default: `None`
                * *version* (`string`) --
                   SFDC API version to use e.g. '39.0'
        """

        self.username = args[0]
        self.password = args[1]
        self.client_id = args[2]
        self.client_secret = args[3]
        self.protocol = kwargs.get('protocol')
        self.proxies = kwargs.get('proxies')
        self.instance_url = None
        self.logger = logging.getLogger('sfdc_py')
        self.logger.setLevel(logging.FATAL)
        self.logger.addHandler(logging.StreamHandler())
        self.client_api_version = None
        self.client_kwargs = kwargs
        self.session_id = None
        self.chatter = chatter.Chatter(self)
        self.jobs = jobs.Jobs(self)
        self.wave = wave.Wave(self)