本文整理汇总了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())
示例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
示例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
示例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):