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


Python LogLevel.info方法代码示例

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


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

示例1: test_doStartLoggingStatement

# 需要导入模块: from twisted.logger import LogLevel [as 别名]
# 或者: from twisted.logger.LogLevel import info [as 别名]
def test_doStartLoggingStatement(self):
        """
        L{Factory.doStart} logs that it is starting a factory, followed by
        the L{repr} of the L{Factory} instance that is being started.
        """
        events = []
        globalLogPublisher.addObserver(events.append)
        self.addCleanup(
            lambda: globalLogPublisher.removeObserver(events.append))

        f = Factory()
        f.doStart()

        self.assertIs(events[0]['factory'], f)
        self.assertEqual(events[0]['log_level'], LogLevel.info)
        self.assertEqual(events[0]['log_format'],
                         'Starting factory {factory!r}') 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:19,代码来源:test_protocol.py

示例2: test_doStopLoggingStatement

# 需要导入模块: from twisted.logger import LogLevel [as 别名]
# 或者: from twisted.logger.LogLevel import info [as 别名]
def test_doStopLoggingStatement(self):
        """
        L{Factory.doStop} logs that it is stopping a factory, followed by
        the L{repr} of the L{Factory} instance that is being stopped.
        """
        events = []
        globalLogPublisher.addObserver(events.append)
        self.addCleanup(
            lambda: globalLogPublisher.removeObserver(events.append))

        class MyFactory(Factory):
            numPorts = 1

        f = MyFactory()
        f.doStop()

        self.assertIs(events[0]['factory'], f)
        self.assertEqual(events[0]['log_level'], LogLevel.info)
        self.assertEqual(events[0]['log_format'],
                         'Stopping factory {factory!r}') 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:22,代码来源:test_protocol.py

示例3: test_runnerOptions

# 需要导入模块: from twisted.logger import LogLevel [as 别名]
# 或者: from twisted.logger.LogLevel import info [as 别名]
def test_runnerOptions(self):
        """
        L{Twist.runnerOptions} translates L{TwistOptions} to a L{RunnerOptions}
        map.
        """
        options = Twist.options([
            "twist", "--reactor=default", "--log-format=json", "web"
        ])

        self.assertEqual(
            Twist.runnerOptions(options),
            {
                RunnerOptions.reactor: self.installedReactors["default"],
                RunnerOptions.defaultLogLevel: LogLevel.info,
                RunnerOptions.logFile: stdout,
                RunnerOptions.fileLogObserverFactory: jsonFileLogObserver,
            }
        ) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:20,代码来源:test_twist.py

示例4: testImplicitHead

# 需要导入模块: from twisted.logger import LogLevel [as 别名]
# 或者: from twisted.logger.LogLevel import info [as 别名]
def testImplicitHead(self):
        logObserver = EventLoggingObserver.createWithCleanup(
            self,
            globalLogPublisher
        )

        req = self._getReq()
        req.requestReceived(b'HEAD', b'/newrender', b'HTTP/1.0')
        self.assertEqual(req.code, 200)
        self.assertEqual(
            -1, req.transport.written.getvalue().find(b'hi hi')
        )

        self.assertEquals(1, len(logObserver))
        event = logObserver[0]
        self.assertEquals(event["log_level"], LogLevel.info) 
开发者ID:wistbean,项目名称:learn_python3_spider,代码行数:18,代码来源:test_web.py

示例5: test_capture

# 需要导入模块: from twisted.logger import LogLevel [as 别名]
# 或者: from twisted.logger.LogLevel import info [as 别名]
def test_capture(self):
        """
        Events logged within context are captured.
        """
        foo = object()

        with capturedLogs() as captured:
            self.log.debug("Capture this, please", foo=foo)
            self.log.info("Capture this too, please", foo=foo)

        self.assertTrue(len(captured) == 2)
        self.assertEqual(captured[0]["log_format"], "Capture this, please")
        self.assertEqual(captured[0]["log_level"], LogLevel.debug)
        self.assertEqual(captured[0]["foo"], foo)
        self.assertEqual(captured[1]["log_format"], "Capture this too, please")
        self.assertEqual(captured[1]["log_level"], LogLevel.info)
        self.assertEqual(captured[1]["foo"], foo) 
开发者ID:wistbean,项目名称:learn_python3_spider,代码行数:19,代码来源:test_capture.py

示例6: init

# 需要导入模块: from twisted.logger import LogLevel [as 别名]
# 或者: from twisted.logger.LogLevel import info [as 别名]
def init(outFile):
    level = levels[config.LOG_LEVEL]
    predicate = LogLevelFilterPredicate(defaultLogLevel=level)
    observer = FilteringLogObserver(textFileLogObserver(outFile=outFile), [predicate])
    observer._encoding = "utf-8"
    globalLogPublisher.addObserver(observer)
    log.info("Start logging with {l}", l=level) 
开发者ID:moira-alert,项目名称:worker,代码行数:9,代码来源:logs.py

示例7: test_main

# 需要导入模块: from twisted.logger import LogLevel [as 别名]
# 或者: from twisted.logger.LogLevel import info [as 别名]
def test_main(self):
        """
        L{Twist.run} runs the runner with options corresponding to the given
        arguments.
        """
        self.patchStartService()

        runners = []

        class Runner(object):
            def __init__(self, options):
                self.options = options
                self.runs = 0
                runners.append(self)

            def run(self):
                self.runs += 1

        self.patch(_twist, "Runner", Runner)

        Twist.main([
            "twist", "--reactor=default", "--log-format=json", "web"
        ])

        self.assertEqual(len(self.serviceStarts), 1)
        self.assertEqual(len(runners), 1)
        self.assertEqual(
            runners[0].options,
            {
                RunnerOptions.reactor: self.installedReactors["default"],
                RunnerOptions.defaultLogLevel: LogLevel.info,
                RunnerOptions.logFile: stdout,
                RunnerOptions.fileLogObserverFactory: jsonFileLogObserver,
            }
        )
        self.assertEqual(runners[0].runs, 1) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:38,代码来源:test_twist.py

示例8: test_old_style

# 需要导入模块: from twisted.logger import LogLevel [as 别名]
# 或者: from twisted.logger.LogLevel import info [as 别名]
def test_old_style(self):
        """
        L{Logger} handles old style log strings.
        """
        observer = LogPublisher()

        observed = []
        observer.addObserver(observed.append)

        sio = StringIO()
        observer.addObserver(textFileLogObserver(sio))

        logger = Logger(observer=observer)

        index = 0
        logger.info("test")
        self.assertEqual(observed[index]["log_level"], LogLevel.info)
        self.assertEqual(observed[index]["log_format"], u"{msg}")
        self.assertEqual(observed[index]["msg"], u"test")
        self.assertEqual(sio.getvalue().splitlines()[index].split("#info] ")[1], "test")

        index += 1
        logger.info("test {}")
        self.assertEqual(observed[index]["log_level"], LogLevel.info)
        self.assertEqual(observed[index]["log_format"], u"{msg}")
        self.assertEqual(observed[index]["msg"], u"test {}")
        self.assertEqual(sio.getvalue().splitlines()[index].split("#info] ")[1], "test {}")

        index += 1
        logger.info("test {foo}")
        self.assertEqual(observed[index]["log_level"], LogLevel.info)
        self.assertEqual(observed[index]["log_format"], u"{msg}")
        self.assertEqual(observed[index]["msg"], u"test {foo}")
        self.assertEqual(sio.getvalue().splitlines()[index].split("#info] ")[1], "test {foo}") 
开发者ID:apple,项目名称:ccs-twistedextensions,代码行数:36,代码来源:test_log.py

示例9: test_utf8

# 需要导入模块: from twisted.logger import LogLevel [as 别名]
# 或者: from twisted.logger.LogLevel import info [as 别名]
def test_utf8(self):
        """
        L{Logger} handles utf8 log strings and format args.
        """
        observer = LogPublisher()

        observed = []
        observer.addObserver(observed.append)

        sio = StringIO()
        observer.addObserver(textFileLogObserver(sio))

        logger = Logger(observer=observer)

        index = 0
        logger.info("t\xc3\xa9st")
        self.assertEqual(observed[index]["log_level"], LogLevel.info)
        self.assertEqual(observed[index]["log_format"], u"{msg}")
        self.assertEqual(observed[index]["msg"], u"t\xe9st")
        self.assertEqual(sio.getvalue().splitlines()[index].split("#info] ")[1], "t\xc3\xa9st")

        index += 1
        logger.info("{str}", str="t\xc3\xa9st")
        self.assertEqual(observed[index]["log_level"], LogLevel.info)
        self.assertEqual(observed[index]["log_format"], u"{str}")
        self.assertEqual(observed[index]["str"], u"t\xe9st")
        self.assertEqual(sio.getvalue().splitlines()[index].split("#info] ")[1], "t\xc3\xa9st")

        index += 1
        logger.info("T\xc3\xa9st {str}", str="t\xc3\xa9st")
        self.assertEqual(observed[index]["log_level"], LogLevel.info)
        self.assertEqual(observed[index]["log_format"], u"T\xe9st {str}")
        self.assertEqual(observed[index]["str"], u"t\xe9st")
        self.assertEqual(sio.getvalue().splitlines()[index].split("#info] ")[1], "T\xc3\xa9st t\xc3\xa9st") 
开发者ID:apple,项目名称:ccs-twistedextensions,代码行数:36,代码来源:test_log.py

示例10: __get__

# 需要导入模块: from twisted.logger import LogLevel [as 别名]
# 或者: from twisted.logger.LogLevel import info [as 别名]
def __get__(self, oself, type=None):
        # this causes the Logger to lie about the "source=", but
        # otherwise we create a new Logger instance every time we do
        # "self.log.info()" if we use it like:
        # class Foo:
        #     log = make_logger
        return self 
开发者ID:crossbario,项目名称:txaio,代码行数:9,代码来源:tx.py

示例11: start_logging

# 需要导入模块: from twisted.logger import LogLevel [as 别名]
# 或者: from twisted.logger.LogLevel import info [as 别名]
def start_logging(out=_stdout, level='info'):
    """
    Start logging to the file-like object in ``out``. By default, this
    is stdout.
    """
    global _loggers, _observer, _log_level, _started_logging

    if level not in log_levels:
        raise RuntimeError(
            "Invalid log level '{0}'; valid are: {1}".format(
                level, ', '.join(log_levels)
            )
        )

    if _started_logging:
        return

    _started_logging = True

    _log_level = level
    set_global_log_level(_log_level)

    if out:
        _observer = _LogObserver(out)

    _observers = []
    if _observer:
        _observers.append(_observer)
    globalLogBeginner.beginLoggingTo(_observers) 
开发者ID:crossbario,项目名称:txaio,代码行数:31,代码来源:tx.py

示例12: test_run

# 需要导入模块: from twisted.logger import LogLevel [as 别名]
# 或者: from twisted.logger.LogLevel import info [as 别名]
def test_run(self):
        """
        L{Twist.run} runs the runner with arguments corresponding to the given
        options.
        """
        argsSeen = []

        self.patch(
            Runner, "__init__", lambda self, **args: argsSeen.append(args)
        )
        self.patch(
            Runner, "run", lambda self: None
        )

        twistOptions = Twist.options([
            "twist", "--reactor=default", "--log-format=json", "web"
        ])
        Twist.run(twistOptions)

        self.assertEqual(len(argsSeen), 1)
        self.assertEqual(
            argsSeen[0],
            dict(
                reactor=self.installedReactors["default"],
                defaultLogLevel=LogLevel.info,
                logFile=stdout,
                fileLogObserverFactory=jsonFileLogObserver,
            )
        ) 
开发者ID:wistbean,项目名称:learn_python3_spider,代码行数:31,代码来源:test_twist.py

示例13: test_main

# 需要导入模块: from twisted.logger import LogLevel [as 别名]
# 或者: from twisted.logger.LogLevel import info [as 别名]
def test_main(self):
        """
        L{Twist.main} runs the runner with arguments corresponding to the given
        command line arguments.
        """
        self.patchStartService()

        runners = []

        class Runner(object):
            def __init__(self, **kwargs):
                self.args = kwargs
                self.runs = 0
                runners.append(self)

            def run(self):
                self.runs += 1

        self.patch(_twist, "Runner", Runner)

        Twist.main([
            "twist", "--reactor=default", "--log-format=json", "web"
        ])

        self.assertEqual(len(self.serviceStarts), 1)
        self.assertEqual(len(runners), 1)
        self.assertEqual(
            runners[0].args,
            dict(
                reactor=self.installedReactors["default"],
                defaultLogLevel=LogLevel.info,
                logFile=stdout,
                fileLogObserverFactory=jsonFileLogObserver,
            )
        )
        self.assertEqual(runners[0].runs, 1) 
开发者ID:wistbean,项目名称:learn_python3_spider,代码行数:38,代码来源:test_twist.py

示例14: checkConfiguration

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

        uid, gid = None, None

        if self.parent["uid"] or self.parent["gid"]:
            uid, gid = getid(self.parent["uid"], self.parent["gid"])

        def gottaBeRoot():
            if getuid() != 0:
                username = getpwuid(getuid()).pw_name
                raise UsageError(
                    "Only root can drop privileges.  You are: {}"
                    .format(username)
                )

        if uid and uid != getuid():
            gottaBeRoot()

        if gid and gid != getgid():
            gottaBeRoot()

        self.parent["pidfile"] = config.PIDFile

        self.checkDirectories(config)

        # Check current umask and warn if changed
        oldmask = umask(config.umask)
        if oldmask != config.umask:
            self.log.info(
                "WARNING: changing umask from: 0{old:03o} to 0{new:03o}",
                old=oldmask, new=config.umask
            )
        self.parent["umask"] = config.umask 
开发者ID:apple,项目名称:ccs-calendarserver,代码行数:35,代码来源:caldav.py

示例15: observe_tftp

# 需要导入模块: from twisted.logger import LogLevel [as 别名]
# 或者: from twisted.logger.LogLevel import info [as 别名]
def observe_tftp(event, forwardTo=globalLogPublisher):
    if "log_level" in event and event["log_level"] is LogLevel.info:
        # Informational messages emitted by `python-tx-tftp` are, in the
        # context of MAAS, debug level at most.
        event["log_level"] = LogLevel.debug
    forwardTo(event) 
开发者ID:maas,项目名称:maas,代码行数:8,代码来源:_tftp.py


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