当前位置: 首页>>代码示例>>Python>>正文


Python logbook.ERROR属性代码示例

本文整理汇总了Python中logbook.ERROR属性的典型用法代码示例。如果您正苦于以下问题:Python logbook.ERROR属性的具体用法?Python logbook.ERROR怎么用?Python logbook.ERROR使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在logbook的用法示例。


在下文中一共展示了logbook.ERROR属性的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: filter_keyed_by_status

# 需要导入模块: import logbook [as 别名]
# 或者: from logbook import ERROR [as 别名]
def filter_keyed_by_status(keys, values_with_status, context=None, level=logbook.ERROR):
  """Filter `values_with_status` (a `list` of `(bool, value)`); return dict with corresponding keys.

  >>> dict(filter_keyed_by_status(['one', 'two'], [(True, 'foo'), (False, 'bar')]))
  {'one': 'foo'}

  """

  values = collections.OrderedDict()
  for key, (status, value_or_traceback) in zip(keys, values_with_status):
    if not status:
      logger.log(level, "[{!s}] failed to retrieve data for '{!s}':\n{!s}", context, key,
          value_or_traceback)
    else:
      values[key] = value_or_traceback
  return values 
开发者ID:Netflix-Skunkworks,项目名称:stethoscope,代码行数:18,代码来源:utils.py

示例2: __get_logbook_logging_level

# 需要导入模块: import logbook [as 别名]
# 或者: from logbook import ERROR [as 别名]
def __get_logbook_logging_level(level_str):
        # logbook levels:
        # CRITICAL = 15
        # ERROR = 14
        # WARNING = 13
        # NOTICE = 12
        # INFO = 11
        # DEBUG = 10
        # TRACE = 9
        # NOTSET = 0

        level_str = level_str.upper().strip()

        if level_str == 'CRITICAL':
            return logbook.CRITICAL
        elif level_str == 'ERROR':
            return logbook.ERROR
        elif level_str == 'WARNING':
            return logbook.WARNING
        elif level_str == 'NOTICE':
            return logbook.NOTICE
        elif level_str == 'INFO':
            return logbook.INFO
        elif level_str == 'DEBUG':
            return logbook.DEBUG
        elif level_str == 'TRACE':
            return logbook.TRACE
        elif level_str == 'NOTSET':
            return logbook.NOTSET
        else:
            raise ValueError("Unknown logbook log level: {}".format(level_str)) 
开发者ID:mikeckennedy,项目名称:python-for-entrepreneurs-course-demos,代码行数:33,代码来源:log_service.py

示例3: _get_logging_level

# 需要导入模块: import logbook [as 别名]
# 或者: from logbook import ERROR [as 别名]
def _get_logging_level(verbosity: int) -> LogbookLevel:
    import logbook
    return LogbookLevel({
        1: logbook.CRITICAL,
        2: logbook.ERROR,
        3: logbook.WARNING,
        4: logbook.NOTICE,
        5: logbook.INFO,
        6: logbook.DEBUG,
        7: logbook.TRACE,
    }[verbosity]) 
开发者ID:saltyrtc,项目名称:saltyrtc-server-python,代码行数:13,代码来源:bin.py

示例4: log_handler

# 需要导入模块: import logbook [as 别名]
# 或者: from logbook import ERROR [as 别名]
def log_handler(request):
    """
    Return a :class:`logbook.TestHandler` instance where log records
    can be accessed.
    """
    log_handler = logbook.TestHandler(level=logbook.DEBUG, bubble=True)
    log_handler._ignore_filter = lambda _: False
    log_handler._error_level = logbook.ERROR
    log_handler.push_application()

    def fin():
        log_handler.pop_application()
    request.addfinalizer(fin)

    return log_handler 
开发者ID:saltyrtc,项目名称:saltyrtc-server-python,代码行数:17,代码来源:conftest.py

示例5: parse_log_level

# 需要导入模块: import logbook [as 别名]
# 或者: from logbook import ERROR [as 别名]
def parse_log_level(value):
    # type: (str) -> logbook
    value = value.lower()

    if value == "info":
        return logbook.INFO
    elif value == "warning":
        return logbook.WARNING
    elif value == "error":
        return logbook.ERROR
    elif value == "debug":
        return logbook.DEBUG

    return logbook.WARNING 
开发者ID:matrix-org,项目名称:pantalaimon,代码行数:16,代码来源:config.py

示例6: filter_by_status

# 需要导入模块: import logbook [as 别名]
# 或者: from logbook import ERROR [as 别名]
def filter_by_status(values_with_status, context=None, level=logbook.ERROR):
  """Filter a `list` of `(bool, value)` pairs on the `bool` value, warning on `False` values.

  >>> filter_by_status([(True, 'foo'), (False, 'bar')])
  ['foo']

  """
  values = list()
  for (status, value_or_traceback) in values_with_status:
    if not status:
      logger.log(level, "[{!s}] failed to retrieve data:\n{!s}", context, value_or_traceback)
    else:
      values.append(value_or_traceback)
  return values 
开发者ID:Netflix-Skunkworks,项目名称:stethoscope,代码行数:16,代码来源:utils.py

示例7: _get_devices_by_id

# 需要导入模块: import logbook [as 别名]
# 或者: from logbook import ERROR [as 别名]
def _get_devices_by_id(self, device_ids):
    deferred_list = defer.DeferredList([self._get_device_by_id(device_id) for device_id in
      device_ids], consumeErrors=True)

    # working off JAMF's own data, so shouldn't fail
    deferred_list.addCallback(stethoscope.api.utils.filter_by_status,
        context=sys._getframe().f_code.co_name, level=logbook.ERROR)
    return deferred_list 
开发者ID:Netflix-Skunkworks,项目名称:stethoscope,代码行数:10,代码来源:deferred.py

示例8: get_devices_by_email

# 需要导入模块: import logbook [as 别名]
# 或者: from logbook import ERROR [as 别名]
def get_devices_by_email(self, email):
    deferred_list = defer.DeferredList([
        threads.deferToThread(super(DeferredGoogleDataSource, self)._get_mobile_devices_by_email,
          email),
        threads.deferToThread(super(DeferredGoogleDataSource, self)._get_chromeos_devices_by_email,
          email),
      ], consumeErrors=True)
    deferred_list.addCallback(stethoscope.api.utils.filter_by_status,
        context=sys._getframe().f_code.co_name, level=logbook.ERROR)
    deferred_list.addCallback(chain.from_iterable)
    deferred_list.addCallback(list)
    return deferred_list 
开发者ID:Netflix-Skunkworks,项目名称:stethoscope,代码行数:14,代码来源:deferred.py

示例9: _get_device_details

# 需要导入模块: import logbook [as 别名]
# 或者: from logbook import ERROR [as 别名]
def _get_device_details(self, devices_response):
    # logger.debug("bitfit devices:\n{!s}", json.dumps(devices_response, indent=2))
    deferreds = [self._get_device_by_id(device['id'])
        for device in devices_response.get('items', [])]
    deferred_list = defer.DeferredList(deferreds, consumeErrors=True)

    # shouldn't fail since we're working off bitfit's own data for the inputs
    deferred_list.addCallback(stethoscope.api.utils.filter_by_status,
        context=sys._getframe().f_code.co_name, level=logbook.ERROR)
    return deferred_list 
开发者ID:Netflix-Skunkworks,项目名称:stethoscope,代码行数:12,代码来源:deferred.py

示例10: configure_logging

# 需要导入模块: import logbook [as 别名]
# 或者: from logbook import ERROR [as 别名]
def configure_logging(log_level=None, log_file=None, simplified_console_logs=False):
    """
    This should be called once as early as possible in app startup to configure logging handlers and formatting.

    :param log_level: The level at which to record log messages (DEBUG|INFO|NOTICE|WARNING|ERROR|CRITICAL)
    :type log_level: str
    :param log_file: The file to write logs to, or None to disable logging to a file
    :type log_file: str | None
    :param simplified_console_logs: Whether or not to use the simplified logging format and coloring
    :type simplified_console_logs: bool
    """
    # Set datetimes in log messages to be local timezone instead of UTC
    logbook.set_datetime_format('local')

    # Redirect standard lib logging to capture third-party logs in our log files (e.g., tornado, requests)
    logging.root.setLevel(logging.WARNING)  # don't include DEBUG/INFO/NOTICE-level logs from third parties
    logbook.compat.redirect_logging(set_root_logger_level=False)

    # Add a NullHandler to suppress all log messages lower than our desired log_level. (Otherwise they go to stderr.)
    NullHandler().push_application()

    log_level = log_level or Configuration['log_level']
    format_string, log_colors = _LOG_FORMAT_STRING, _LOG_COLORS
    if simplified_console_logs:
        format_string, log_colors = _SIMPLIFIED_LOG_FORMAT_STRING, _SIMPLIFIED_LOG_COLORS

    # handler for stdout
    log_handler = _ColorizingStreamHandler(
        stream=sys.stdout,
        level=log_level,
        format_string=format_string,
        log_colors=log_colors,
        bubble=True,
    )
    log_handler.push_application()

    # handler for log file
    if log_file:
        fs.create_dir(os.path.dirname(log_file))
        previous_log_file_exists = os.path.exists(log_file)

        event_handler = _ColorizingRotatingFileHandler(
            filename=log_file,
            level=log_level,
            format_string=_LOG_FORMAT_STRING,
            log_colors=_LOG_COLORS,
            bubble=True,
            max_size=Configuration['max_log_file_size'],
            backup_count=Configuration['max_log_file_backups'],
        )
        event_handler.push_application()
        if previous_log_file_exists:
            # Force application to create a new log file on startup.
            event_handler.perform_rollover(increment_logfile_counter=False)
        else:
            event_handler.log_application_summary() 
开发者ID:box,项目名称:ClusterRunner,代码行数:58,代码来源:log.py


注:本文中的logbook.ERROR属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。