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


Python Logger.failure方法代码示例

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


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

示例1: test_logger_namespace_failure

# 需要导入模块: from twisted.logger import Logger [as 别名]
# 或者: from twisted.logger.Logger import failure [as 别名]
    def test_logger_namespace_failure(self):
        """
        An unexpected failure, logged as critical, is displayed across multiple
        lines.
        """
        fout = StringIO()
        log = Logger(namespace="ns", observer=FileLogObserver(fout, formatForSystemd))

        log.failure("Something went wrong", Failure(Exception("1\n2\n3")))

        self.assertEqual((
            "<2>[ns] Something went wrong\n"
            "<2>  Traceback (most recent call last):\n"
            "<2>  Failure: builtins.Exception: 1\n"
            "<2>  2\n"
            "<2>  3\n"
        ), fout.getvalue())
开发者ID:twm,项目名称:yarrharr,代码行数:19,代码来源:test_application.py

示例2: test_log_converter

# 需要导入模块: from twisted.logger import Logger [as 别名]
# 或者: from twisted.logger.Logger import failure [as 别名]
def test_log_converter(handler, framework):
    pytest.importorskip("twisted.logger")
    # this checks that we can convert a plain Twisted Logger calling
    # failure() into a traceback on our observers.
    from twisted.logger import Logger
    from txaio.tx import _LogObserver

    out = six.StringIO()
    observer = _LogObserver(out)
    logger = Logger(observer=observer)

    try:
        raise RuntimeError("failed on purpose")
    except:
        logger.failure(None)

    output = out.getvalue()
    assert "failed on purpose" in output
    assert "Traceback" in output
开发者ID:koobs,项目名称:txaio,代码行数:21,代码来源:test_logging.py

示例3: Logger

# 需要导入模块: from twisted.logger import Logger [as 别名]
# 或者: from twisted.logger.Logger import failure [as 别名]
from twisted.web import http, server
from twisted.logger import Logger, LogLevel
from twisted.application.service import MultiService
from kotori.util.configuration import read_list
from kotori.daq.services import MultiServiceMixin
from kotori.daq.intercom.mqtt import MqttAdapter
from kotori.io.protocol.http import HttpDataFrameResponse
from kotori.io.protocol.util import handleFailure
from kotori.util.errors import last_error_and_traceback

log = Logger()

try:
    from kotori.io.export.influx import DataFrameQuery
except ImportError:
    log.failure('InfluxDB export not available, please install "pandas".', level=LogLevel.warn)

class ForwarderTargetService(MultiServiceMixin, MultiService):
    """
    Container service for target services.

    As of June 2016, there are currently two target
    services for emitting data, MQTT and InfluxDB.
    """

    def __init__(self, address=None, **kwargs):
        MultiServiceMixin.__init__(self, **kwargs)

        self.address = address
        self.scheme  = self.address.uri.scheme
开发者ID:hiveeyes,项目名称:kotori,代码行数:32,代码来源:target.py

示例4: Logger

# 需要导入模块: from twisted.logger import Logger [as 别名]
# 或者: from twisted.logger.Logger import failure [as 别名]
# -*- coding: utf-8 -*-
# (c) 2016 Andreas Motl <[email protected]>
import tempfile
from pprint import pprint
from twisted.logger import Logger, LogLevel
from twisted.web.template import renderElement
from kotori.io.export.html import DatatablesPage
from kotori.io.protocol.util import get_data_uri
from kotori.io.export.util import dataframe_index_and_sort

log = Logger()

try:
    import pandas
except ImportError:
    log.failure('Tabular export not available, please install "pandas".', level=LogLevel.warn)

class UniversalTabularExporter(object):
    """
    Universal exporter for tabular data.

    Render pandas DataFrame to Excel (XLSX), HDF5
    and NetCDF formats and as DataTables HTML widget.
    """

    def __init__(self, bucket, dataframe):
        self.bucket = bucket
        self.request = bucket.request
        self.dataframe = dataframe

    def render(self, format, kind=None, buffer=None):
开发者ID:hiveeyes,项目名称:kotori,代码行数:33,代码来源:tabular.py


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