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


Python logger.Logger方法代码示例

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


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

示例1: test_log_error_if_fetch_by_fingerprint_returns_wrong_key

# 需要导入模块: from twisted import logger [as 别名]
# 或者: from twisted.logger import Logger [as 别名]
def test_log_error_if_fetch_by_fingerprint_returns_wrong_key(self):
        pgp = openpgp.OpenPGPScheme(
            self._soledad, gpgbinary=self.gpg_binary_path)
        km = self._key_manager()

        with patch.object(Logger, 'error') as mock_logger_error:
            rf = RandomRefreshPublicKey(pgp, km)
            rf._get_random_key = \
                Mock(return_value=defer.succeed(OpenPGPKey(
                    fingerprint=KEY_FINGERPRINT)))

            km._nicknym.fetch_key_with_fingerprint = \
                Mock(return_value=defer.succeed(PUBLIC_KEY_2))

            yield rf.maybe_refresh_key()

            mock_logger_error.assert_called_with(
                ERROR_UNEQUAL_FINGERPRINTS %
                (KEY_FINGERPRINT, KEY_FINGERPRINT_2)) 
开发者ID:leapcode,项目名称:bitmask-dev,代码行数:21,代码来源:test_refresher.py

示例2: testLogErrorIfDecryptFails

# 需要导入模块: from twisted import logger [as 别名]
# 或者: from twisted.logger import Logger [as 别名]
def testLogErrorIfDecryptFails(self):

        def assert_failure(_):
            mock_logger_error.assert_any_call('_decrypt_doc: '
                                              'Error decrypting document with '
                                              'ID 1')

        with patch.object(Logger, 'error') as mock_logger_error:
            doc = SoledadDocument()
            doc.doc_id = '1'
            doc.content = {'_enc_json': ''}

            self.fetcher._process_decrypted_doc = Mock()
            self.km.decrypt = Mock(
                return_value=defer.fail(Exception()))

            d = self.fetcher._decrypt_doc(doc)
            d.addCallback(assert_failure)
            return d 
开发者ID:leapcode,项目名称:bitmask-dev,代码行数:21,代码来源:test_incoming_mail.py

示例3: testFlagMessageOnBadJsonWhileDecrypting

# 需要导入模块: from twisted import logger [as 别名]
# 或者: from twisted.logger import Logger [as 别名]
def testFlagMessageOnBadJsonWhileDecrypting(self):
        doc = SoledadDocument()
        doc.doc_id = '1'
        doc.content = {'_enc_json': ''}

        err = ValueError('No JSON object could be decoded')

        def assert_failure():
            mock_logger_error.assert_any_call(
                'Error while decrypting 1')
            mock_logger_error.assert_any_call(
                'No JSON object could be decoded')
            self.assertEquals(doc.content['errdecr'], True)

        with patch.object(Logger, 'error') as mock_logger_error:
            with patch.object(utils, 'json_loads') as mock_json_loader:
                self.fetcher._update_incoming_message = Mock()
                mock_json_loader.side_effect = err

                self.fetcher._process_decrypted_doc(doc, '')

                assert_failure() 
开发者ID:leapcode,项目名称:bitmask-dev,代码行数:24,代码来源:test_incoming_mail.py

示例4: __init__

# 需要导入模块: from twisted import logger [as 别名]
# 或者: from twisted.logger import Logger [as 别名]
def __init__(self, endpoint, factory, retryPolicy, clock, log):
        """
        @see: L{ClientService.__init__}

        @param log: The logger for the L{ClientService} instance this state
            machine is associated to.
        @type log: L{Logger}
        """
        self._endpoint = endpoint
        self._failedAttempts = 0
        self._stopped = False
        self._factory = factory
        self._timeoutForAttempt = retryPolicy
        self._clock = clock
        self._connectionInProgress = succeed(None)

        self._awaitingConnected = []

        self._stopWaiters = []
        self._log = log 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:22,代码来源:internet.py

示例5: __init__

# 需要导入模块: from twisted import logger [as 别名]
# 或者: from twisted.logger import Logger [as 别名]
def __init__(self, conf, router_conf, metrics):
        """Create a new FCM router and connect to FCM"""
        self.conf = conf
        self.router_conf = router_conf
        self.metrics = metrics
        self.min_ttl = router_conf.get("ttl", 60)
        self.dryRun = router_conf.get("dryrun", False)
        self.collapseKey = router_conf.get("collapseKey", "webpush")
        self.version = router_conf["version"]
        self.log = Logger()
        self.clients = {}
        try:
            for (sid, creds) in router_conf["creds"].items():
                self.clients[sid] = FCMv1(
                    project_id=creds["projectid"],
                    service_cred_path=creds["auth"],
                    logger=self.log,
                    metrics=self.metrics)
        except Exception as e:
            self.log.error("Could not instantiate FCMv1: missing credentials,",
                           ex=e)
            raise IOError("FCMv1 Bridge not initiated in main")
        self._base_tags = ["platform:fcmv1"]
        self.log.debug("Starting FCMv1 router...") 
开发者ID:mozilla-services,项目名称:autopush,代码行数:26,代码来源:fcm_v1.py

示例6: __init__

# 需要导入模块: from twisted import logger [as 别名]
# 或者: from twisted.logger import Logger [as 别名]
def __init__(self,
                 project_id,
                 service_cred_path=None,
                 logger=None,
                 metrics=None,
                 **options):
        self.project_id = project_id
        self.endpoint = ("https://fcm.googleapis.com/v1/"
                         "projects/{}/messages:send".format(self.project_id))

        self.token = None
        self.metrics = metrics
        self.logger = logger or Logger()
        self._options = options
        if service_cred_path:
            self.svc_cred = ServiceAccountCredentials.from_json_keyfile_name(
                service_cred_path,
                ["https://www.googleapis.com/auth/firebase.messaging"])
        self._sender = treq.post 
开发者ID:mozilla-services,项目名称:autopush,代码行数:21,代码来源:fcmv1client.py

示例7: make_logger

# 需要导入模块: from twisted import logger [as 别名]
# 或者: from twisted.logger import Logger [as 别名]
def make_logger(level=None, logger=_Logger, observer=None):
    # we want the namespace to be the calling context of "make_logger"
    # -- so we *have* to pass namespace kwarg to Logger (or else it
    # will always say the context is "make_logger")
    cf = inspect.currentframe().f_back
    if "self" in cf.f_locals:
        # We're probably in a class init or method
        cls = cf.f_locals["self"].__class__
        namespace = '{0}.{1}'.format(cls.__module__, cls.__name__)
    else:
        namespace = cf.f_globals["__name__"]
        if cf.f_code.co_name != "<module>":
            # If it's not the module, and not in a class instance, add the code
            # object's name.
            namespace = namespace + "." + cf.f_code.co_name
    logger = Logger(level=level, namespace=namespace, logger=logger,
                    observer=observer)
    return logger 
开发者ID:crossbario,项目名称:txaio,代码行数:20,代码来源:tx.py

示例8: test_log_converter

# 需要导入模块: from twisted import logger [as 别名]
# 或者: from twisted.logger import Logger [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 = StringIO()
    observer = _LogObserver(out)
    logger = Logger(observer=observer)

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

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

示例9: setUp

# 需要导入模块: from twisted import logger [as 别名]
# 或者: from twisted.logger import Logger [as 别名]
def setUp(self):
        """
        Override some things in mailmail, so that we capture C{stdout},
        and do not call L{reactor.stop}.
        """
        self.out = NativeStringIO()
        # Override the mailmail logger, so we capture stderr output
        from twisted.logger import textFileLogObserver, Logger
        logObserver = textFileLogObserver(self.out)
        self.patch(mailmail, '_log', Logger(observer=logObserver))
        self.host = None
        self.options = None
        self.ident = None

        # Override mailmail.sendmail, so we don't call reactor.stop()
        def sendmail(host, options, ident):
            self.host = host
            self.options = options
            self.ident = ident
            return smtp.sendmail(host, options.sender, options.to,
                                 options.body, reactor=self.memoryReactor)

        self.patch(mailmail, 'sendmail', sendmail) 
开发者ID:wistbean,项目名称:learn_python3_spider,代码行数:25,代码来源:test_mailmail.py

示例10: install

# 需要导入模块: from twisted import logger [as 别名]
# 或者: from twisted.logger import Logger [as 别名]
def install(cls, module, attribute="log", *, source=None, observer=None):
        """Install a `LegacyLogger` at `module.attribute`.

        Warns if `module.attribute` does not exist, but carries on anyway.

        :param module: A module (or any other object with assignable
            attributes and a `__name__`).
        :param attribute: The name of the attribute on `module` to replace.
        :param source: See `Logger.__init__`.
        :param observer: See `Logger.__init__`.
        :return: The newly created `LegacyLogger`.
        """
        replacing = getattr(module, attribute, "<not-found>")
        warn_unless(
            replacing is twistedLegacy,
            (
                "Legacy logger being installed to replace %r but expected a "
                "reference to twisted.python.log module; please investigate!"
                % (replacing,)
            ),
        )
        logger = cls(module.__name__, source=source, observer=observer)
        setattr(module, attribute, logger)
        return logger 
开发者ID:maas,项目名称:maas,代码行数:26,代码来源:_twisted.py

示例11: __init__

# 需要导入模块: from twisted import logger [as 别名]
# 或者: from twisted.logger import Logger [as 别名]
def __init__(self, alias="default"):
        self.alias = alias
        self.listeners = defaultdict(list)
        self.autoReconnect = False
        self.connection = None
        self.connectionFileno = None
        self.notifications = set()
        self.notifier = task.LoopingCall(self.handleNotifies)
        self.notifierDone = None
        self.connecting = None
        self.disconnecting = None
        self.registeredChannels = set()
        self.channelRegistrar = task.LoopingCall(
            lambda: ensureDeferred(self.registerChannels())
        )
        self.channelRegistrarDone = None
        self.log = Logger(__name__, self)
        self.events = EventGroup("connected", "disconnected") 
开发者ID:maas,项目名称:maas,代码行数:20,代码来源:listener.py

示例12: audit

# 需要导入模块: from twisted import logger [as 别名]
# 或者: from twisted.logger import Logger [as 别名]
def audit():
    outFile = sys.stdout if config.LOG_DIRECTORY == "stdout" else daily("audit.log")
    observer = textFileLogObserver(outFile=outFile)
    observer._encoding = "utf-8"
    return Logger(observer=observer) 
开发者ID:moira-alert,项目名称:worker,代码行数:7,代码来源:logs.py

示例13: test_start_refreshing

# 需要导入模块: from twisted import logger [as 别名]
# 或者: from twisted.logger import Logger [as 别名]
def test_start_refreshing(self):
        pgp = openpgp.OpenPGPScheme(
            self._soledad, gpgbinary=self.gpg_binary_path)

        with patch.object(Logger, 'debug') as mock_logger_start:
            rf = RandomRefreshPublicKey(pgp, self._key_manager())
            rf.start()
            mock_logger_start.assert_called_with(DEBUG_START_REFRESH)
            rf.stop()
            mock_logger_start.assert_called_with(DEBUG_STOP_REFRESH) 
开发者ID:leapcode,项目名称:bitmask-dev,代码行数:12,代码来源:test_refresher.py

示例14: __init__

# 需要导入模块: from twisted import logger [as 别名]
# 或者: from twisted.logger import Logger [as 别名]
def __init__(self, bus, topic, transform, logger):
        self.bus = bus
        self.topic = topic
        self.transform = to_list(transform)
        self.log = logger or Logger()

        # TODO sanity checks 
开发者ID:daq-tools,项目名称:kotori,代码行数:9,代码来源:udp.py

示例15: log_exception

# 需要导入模块: from twisted import logger [as 别名]
# 或者: from twisted.logger import Logger [as 别名]
def log_exception(func):
    """Exception Logger Decorator for protocol methods"""
    @wraps(func)
    def wrapper(self, *args, **kwargs):
        try:
            return func(self, *args, **kwargs)
        except Exception:
            if self._log_exc:
                self.log_failure(failure.Failure())
            else:
                raise
    return wrapper 
开发者ID:mozilla-services,项目名称:autopush,代码行数:14,代码来源:websocket.py


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