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


Python LogLevel.error方法代码示例

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


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

示例1: test_event_on_connection

# 需要导入模块: from twisted.logger import LogLevel [as 别名]
# 或者: from twisted.logger.LogLevel import error [as 别名]
def test_event_on_connection(self):
        listener = PostgresListenerService()
        start_calls = []
        stop_calls = []
        listener.events.connected.registerHandler(
            lambda: start_calls.append(True)
        )
        listener.events.disconnected.registerHandler(
            lambda reason: stop_calls.append(reason)
        )
        yield listener.startService()
        self.assertEqual(len(start_calls), 1)
        yield listener.stopService()
        self.assertEqual(len(stop_calls), 1)
        [failure] = stop_calls
        self.assertIsInstance(failure.value, error.ConnectionDone) 
开发者ID:maas,项目名称:maas,代码行数:18,代码来源:test_listener.py

示例2: classify_topic

# 需要导入模块: from twisted.logger import LogLevel [as 别名]
# 或者: from twisted.logger.LogLevel import error [as 别名]
def classify_topic(self, topic):
        if TopicMatchers.data.search(topic): return MessageType.DATA_CONTAINER
        if TopicMatchers.discrete.search(topic): return MessageType.DATA_DISCRETE
        if TopicMatchers.event.search(topic): return MessageType.EVENT
        if TopicMatchers.error.search(topic): return MessageType.ERROR 
开发者ID:daq-tools,项目名称:kotori,代码行数:7,代码来源:mig.py

示例3: emit_message

# 需要导入模块: from twisted.logger import LogLevel [as 别名]
# 或者: from twisted.logger.LogLevel import error [as 别名]
def emit_message(self, message):

        # Compute storage location from topology information.
        storage_location = self.strategy.topology_to_storage(message.topology, message_type=message.type)
        log.debug(u'Storage location: {storage}', storage=dict(storage_location))

        # Store data or event.
        if message.type in (MessageType.DATA_CONTAINER, MessageType.EVENT):
            self.store_message(storage_location, message.data)

        # Provision graphing subsystem.
        if message.type == MessageType.DATA_CONTAINER:
            # TODO: Purge message from fields to be used as tags
            # Namely:
            # 'geohash',
            # 'location', 'location_id', 'location_name', 'sensor_id', 'sensor_type',
            # 'latitude', 'longitude', 'lat', 'lon'
            for graphing_subsystem in self.graphing:

                # Mix in references to each other. A bit of a hack, but okay for now :-).
                graphing_subsystem.strategy = self.strategy

                subsystem_name = graphing_subsystem.__class__.__name__
                log.debug(u'Provisioning Grafana with {name}', name=subsystem_name)
                try:
                    graphing_subsystem.provision(storage_location, message.data, topology=message.topology)

                except Exception as ex:
                    log.failure(u'Grafana provisioning failed for storage={storage}, message={message}:\n{log_failure}',
                                storage=storage_location.dump(), message=message.data,
                                level=LogLevel.error)

                    return Failure(Exception('Grafana provisioning failed'))

        return True 
开发者ID:daq-tools,项目名称:kotori,代码行数:37,代码来源:mig.py

示例4: mqtt_process_error

# 需要导入模块: from twisted.logger import LogLevel [as 别名]
# 或者: from twisted.logger.LogLevel import error [as 别名]
def mqtt_process_error(self, failure, topic, payload):
        """
        Failure handling

        :param failure: Failure object from Twisted
        :param topic:   Full MQTT topic
        :param payload: Raw MQTT payload
        """

        # Log failure
        log.failure(u'Processing MQTT message failed from topic "{topic}":\n{log_failure}', topic=topic, failure=failure, level=LogLevel.error)

        # MQTT error signalling
        self.mqtt_publish_error(failure, topic, payload) 
开发者ID:daq-tools,项目名称:kotori,代码行数:16,代码来源:mig.py

示例5: mqtt_exception

# 需要导入模块: from twisted.logger import LogLevel [as 别名]
# 或者: from twisted.logger.LogLevel import error [as 别名]
def mqtt_exception(self, failure, topic, payload):
        log.failure(u'Problem publishing error message:\n{log_failure}', failure=failure, level=LogLevel.warn) 
开发者ID:daq-tools,项目名称:kotori,代码行数:4,代码来源:mig.py

示例6: _set_log_level

# 需要导入模块: from twisted.logger import LogLevel [as 别名]
# 或者: from twisted.logger.LogLevel import error [as 别名]
def _set_log_level(self, level):
        # up to the desired level, we don't do anything, as we're a
        # "real" Twisted new-logger; for methods *after* the desired
        # level, we bind to the no_op method
        desired_index = log_levels.index(level)

        for (idx, name) in enumerate(log_levels):
            if name == 'none':
                continue

            if idx > desired_index:
                current = getattr(self, name, None)
                if not current == _no_op or current is None:
                    setattr(self, name, _no_op)
                if name == 'error':
                    setattr(self, 'failure', _no_op)

            else:
                if getattr(self, name, None) in (_no_op, None):

                    if name == 'trace':
                        setattr(self, "trace", self._trace)
                    else:
                        setattr(self, name,
                                partial(self._log, LogLevel.lookupByName(name)))

                    if name == 'error':
                        setattr(self, "failure", self._failure)

        self._log_level = level 
开发者ID:crossbario,项目名称:txaio,代码行数:32,代码来源:tx.py

示例7: __call__

# 需要导入模块: from twisted.logger import LogLevel [as 别名]
# 或者: from twisted.logger.LogLevel import error [as 别名]
def __call__(self, event):
        # it seems if a twisted.logger.Logger() has .failure() called
        # on it, the log_format will be None for the traceback after
        # "Unhandled error in Deferred" -- perhaps this is a Twisted
        # bug?
        if event['log_format'] is None:
            msg = '{0} {1}{2}'.format(
                formatTime(event["log_time"]),
                failure_format_traceback(event['log_failure']),
                os.linesep,
            )
            if self._encode:
                msg = msg.encode('utf8')
            self._file.write(msg)
        else:
            # although Logger will already have filtered out unwanted
            # levels, bare Logger instances from Twisted code won't have.
            if 'log_level' in event and self._acceptable_level(event['log_level']):
                msg = '{0} {1}{2}'.format(
                    formatTime(event["log_time"]),
                    formatEvent(event),
                    os.linesep,
                )
                if self._encode:
                    msg = msg.encode('utf8')

                self._file.write(msg) 
开发者ID:crossbario,项目名称:txaio,代码行数:29,代码来源:tx.py

示例8: failure_message

# 需要导入模块: from twisted.logger import LogLevel [as 别名]
# 或者: from twisted.logger.LogLevel import error [as 别名]
def failure_message(self, fail):
        """
        :param fail: must be an IFailedFuture
        returns a unicode error-message
        """
        try:
            return '{0}: {1}'.format(
                fail.value.__class__.__name__,
                fail.getErrorMessage(),
            )
        except Exception:
            return 'Failed to produce failure message for "{0}"'.format(fail) 
开发者ID:crossbario,项目名称:txaio,代码行数:14,代码来源:tx.py

示例9: create_future

# 需要导入模块: from twisted.logger import LogLevel [as 别名]
# 或者: from twisted.logger.LogLevel import error [as 别名]
def create_future(self, result=_unspecified, error=_unspecified, canceller=None):
        if result is not _unspecified and error is not _unspecified:
            raise ValueError("Cannot have both result and error.")

        f = Deferred(canceller=canceller)
        if result is not _unspecified:
            resolve(f, result)
        elif error is not _unspecified:
            reject(f, error)
        return f 
开发者ID:crossbario,项目名称:txaio,代码行数:12,代码来源:tx.py

示例10: create_future_error

# 需要导入模块: from twisted.logger import LogLevel [as 别名]
# 或者: from twisted.logger.LogLevel import error [as 别名]
def create_future_error(self, error=None):
        return fail(create_failure(error)) 
开发者ID:crossbario,项目名称:txaio,代码行数:4,代码来源:tx.py

示例11: test_logging

# 需要导入模块: from twisted.logger import LogLevel [as 别名]
# 或者: from twisted.logger.LogLevel import error [as 别名]
def test_logging(self):
        """
        Logging module configures properly.
        """
        defaultLogLevel = Logger.filterPredicate.logLevelForNamespace(None)
        self.assertNotEqual(
            defaultLogLevel, LogLevel.error,
            "This test assumes the default log level is not error."
        )

        config.setDefaults(DEFAULT_CONFIG)
        config.reload()

        self.assertEquals(Logger.filterPredicate.logLevelForNamespace(None), defaultLogLevel)
        self.assertEquals(Logger.filterPredicate.logLevelForNamespace("some.namespace"), defaultLogLevel)

        config.load(self.testConfig)

        self.assertEquals(Logger.filterPredicate.logLevelForNamespace(None), LogLevel.error)
        self.assertEquals(Logger.filterPredicate.logLevelForNamespace("some.namespace"), LogLevel.debug)

        writePlist({}, self.testConfig)
        config.reload()

        self.assertEquals(Logger.filterPredicate.logLevelForNamespace(None), defaultLogLevel)
        self.assertEquals(Logger.filterPredicate.logLevelForNamespace("some.namespace"), defaultLogLevel) 
开发者ID:apple,项目名称:ccs-calendarserver,代码行数:28,代码来源:test_config.py

示例12: testSyncToken

# 需要导入模块: from twisted.logger import LogLevel [as 别名]
# 或者: from twisted.logger.LogLevel import error [as 别名]
def testSyncToken(self):
        config.load(self.testConfig)

        self.assertEquals(
            sorted(config._syncTokenKeys),
            ['Notifications.Services.APNS.CalDAV.Topic',
             'Notifications.Services.APNS.CardDAV.Topic',
             'Notifications.Services.APNS.Enabled',
             'ServerInfoToken']
        )

        # no sync token keys specified; need to empty this array here because
        # stdconfig is registering keys automatically
        config._syncTokenKeys = []
        self.assertEquals("d41d8cd98f00b204e9800998ecf8427e", config.syncToken())

        # add sync token keys (some with multiple levels)
        config.addSyncTokenKey("DefaultLogLevel")
        config.addSyncTokenKey("Notifications.Services.APNS.Enabled")
        config.addSyncTokenKey("Notifications.Services.APNS.CalDAV.Topic")
        config.addSyncTokenKey("Notifications.Services.APNS.CardDAV.Topic")
        self.assertEquals("7473205187d7a6ff0c61a2b6b04053c5", config.syncToken())

        # modify a sync token key value
        config.Notifications.Services.APNS.CalDAV.Topic = "changed"
        # direct manipulation of config requires explicit invalidation
        self.assertEquals("7473205187d7a6ff0c61a2b6b04053c5", config.syncToken())
        config.invalidateSyncToken()
        self.assertEquals("4cdbb3841625d001dc768439f5a88cba", config.syncToken())

        # add a non existent key (not an error because it could exist later)
        config.addSyncTokenKey("Notifications.Services.APNS.CalDAV.NonExistent")
        config.invalidateSyncToken()
        self.assertEquals("2ffb128cee5a4b217cef82fd31ae7767", config.syncToken())

        # reload automatically invalidates
        config.reload()
        self.assertEquals(config._cachedSyncToken, None) 
开发者ID:apple,项目名称:ccs-calendarserver,代码行数:40,代码来源:test_config.py

示例13: twisted_log_observer

# 需要导入模块: from twisted.logger import LogLevel [as 别名]
# 或者: from twisted.logger.LogLevel import error [as 别名]
def twisted_log_observer(event):
    current_loglevel = event.get("log_level")

    # Filter
    # if current_loglevel != LogLevel.critical or current_loglevel != LogLevel.error:
    #     return

    f = twisted_logger_mapping[current_loglevel]
    if 'log_text' in event:
        f("[TWISTED] %s", event['log_text']) 
开发者ID:theQRL,项目名称:QRL,代码行数:12,代码来源:logger_twisted.py

示例14: errors

# 需要导入模块: from twisted.logger import LogLevel [as 别名]
# 或者: from twisted.logger.LogLevel import error [as 别名]
def errors(self):
        """Return a list of events that are at `LogLevel.error` or above.

        This returns a list of event *dictionaries*, not strings.
        """
        return [
            event
            for event in self.events
            if "log_level" in event
            and event["log_level"] is not None
            and event["log_level"] >= LogLevel.error
        ] 
开发者ID:maas,项目名称:maas,代码行数:14,代码来源:twisted.py

示例15: test_tryConnection_logs_error

# 需要导入模块: from twisted.logger import LogLevel [as 别名]
# 或者: from twisted.logger.LogLevel import error [as 别名]
def test_tryConnection_logs_error(self):
        listener = PostgresListenerService()

        exception_type = factory.make_exception_type()
        exception_message = factory.make_name("message")

        startConnection = self.patch(listener, "startConnection")
        startConnection.side_effect = exception_type(exception_message)

        with TwistedLoggerFixture() as logger:
            with ExpectedException(exception_type):
                yield listener.tryConnection()

        self.assertThat(logger.events, HasLength(1))
        self.assertThat(
            logger.events[0],
            ContainsDict(
                {
                    "log_format": Equals(
                        "Unable to connect to database: {error}"
                    ),
                    "log_level": Equals(LogLevel.error),
                    "error": Equals(exception_message),
                }
            ),
        ) 
开发者ID:maas,项目名称:maas,代码行数:28,代码来源:test_listener.py


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