當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。