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


Python _twistd_unix.UnixAppLogger类代码示例

本文整理汇总了Python中twisted.scripts._twistd_unix.UnixAppLogger的典型用法代码示例。如果您正苦于以下问题:Python UnixAppLogger类的具体用法?Python UnixAppLogger怎么用?Python UnixAppLogger使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: test_getLogObserverFile

    def test_getLogObserverFile(self):
        """
        When C{logfile} contains a file name, L{app.AppLogger._getLogObserver}
        returns a log observer pointing at the specified path, and a signal
        handler rotating the log is installed.
        """
        logFiles = _patchFileLogObserver(self.patch)
        filename = self.mktemp()
        logger = UnixAppLogger({"logfile": filename})
        observer = logger._getLogObserver()

        self.assertEquals(len(logFiles), 1)
        self.assertEquals(logFiles[0].path,
                          os.path.abspath(filename))

        self.assertEquals(len(self.signals), 1)
        self.assertEquals(self.signals[0][0], signal.SIGUSR1)

        d = Deferred()
        def rotate():
            d.callback(None)
        logFiles[0].rotate = rotate

        rotateLog = self.signals[0][1]
        rotateLog(None, None)
        return d
开发者ID:P13RR3,项目名称:FrostCore,代码行数:26,代码来源:test_twistd.py

示例2: test_getLogObserverSyslog

 def test_getLogObserverSyslog(self):
     """
     If C{syslog} is set to C{True}, L{UnixAppLogger._getLogObserver} starts
     a L{syslog.SyslogObserver} with given C{prefix}.
     """
     logs = _setupSyslog(self)
     logger = UnixAppLogger({"syslog": True, "prefix": "test-prefix"})
     observer = logger._getLogObserver()
     self.assertEqual(logs, ["test-prefix"])
     observer({"a": "b"})
     self.assertEqual(logs, ["test-prefix", {"a": "b"}])
开发者ID:Juxi,项目名称:OpenSignals,代码行数:11,代码来源:test_twistd.py

示例3: test_getLogObserverDefaultFile

    def test_getLogObserverDefaultFile(self):
        """
        When daemonized and C{logfile} is empty, the observer returned by
        L{UnixAppLogger._getLogObserver} points at C{twistd.log} in the current
        directory.
        """
        logFiles = _patchFileLogObserver(self.patch)
        logger = UnixAppLogger({"logfile": "", "nodaemon": False})
        observer = logger._getLogObserver()

        self.assertEquals(len(logFiles), 1)
        self.assertEquals(logFiles[0].path,
                          os.path.abspath("twistd.log"))
开发者ID:P13RR3,项目名称:FrostCore,代码行数:13,代码来源:test_twistd.py

示例4: test_getLogObserverSyslog

 def test_getLogObserverSyslog(self):
     """
     If C{syslog} is set to C{True}, L{UnixAppLogger._getLogObserver} starts
     a L{syslog.SyslogObserver} with given C{prefix}.
     """
     class fakesyslog(object):
         def openlog(self, prefix):
             self.prefix = prefix
     syslogModule = fakesyslog()
     self.patch(syslog, "syslog", syslogModule)
     logger = UnixAppLogger({"syslog": True, "prefix": "test-prefix"})
     observer = logger._getLogObserver()
     self.assertEquals(syslogModule.prefix, "test-prefix")
开发者ID:Almad,项目名称:twisted,代码行数:13,代码来源:test_twistd.py

示例5: test_getLogObserverSyslog

 def test_getLogObserverSyslog(self):
     """
     If C{syslog} is set to C{True}, L{UnixAppLogger._getLogObserver} starts
     a L{syslog.SyslogObserver} with given C{prefix}.
     """
     class fakesyslogobserver(object):
         def __init__(self, prefix):
             fakesyslogobserver.prefix = prefix
         def emit(self, eventDict):
             pass
     self.patch(syslog, "SyslogObserver", fakesyslogobserver)
     logger = UnixAppLogger({"syslog": True, "prefix": "test-prefix"})
     observer = logger._getLogObserver()
     self.assertEquals(fakesyslogobserver.prefix, "test-prefix")
开发者ID:P13RR3,项目名称:FrostCore,代码行数:14,代码来源:test_twistd.py

示例6: test_getLogObserverDontOverrideSignalHandler

    def test_getLogObserverDontOverrideSignalHandler(self):
        """
        If a signal handler is already installed,
        L{UnixAppLogger._getLogObserver} doesn't override it.
        """
        def fakeGetSignal(sig):
            self.assertEquals(sig, signal.SIGUSR1)
            return object()
        self.patch(signal, "getsignal", fakeGetSignal)
        filename = self.mktemp()
        logger = UnixAppLogger({"logfile": filename})
        observer = logger._getLogObserver()

        self.assertEquals(self.signals, [])
开发者ID:P13RR3,项目名称:FrostCore,代码行数:14,代码来源:test_twistd.py

示例7: test_getLogObserverStdout

    def test_getLogObserverStdout(self):
        """
        When non-daemonized and C{logfile} is empty or set to C{-},
        L{UnixAppLogger._getLogObserver} returns a log observer pointing at
        C{sys.stdout}.
        """
        logFiles = _patchFileLogObserver(self.patch)

        logger = UnixAppLogger({"logfile": "-", "nodaemon": True})
        observer = logger._getLogObserver()
        self.assertEquals(len(logFiles), 1)
        self.assertIdentical(logFiles[0], sys.stdout)

        logger = UnixAppLogger({"logfile": "", "nodaemon": True})
        observer = logger._getLogObserver()
        self.assertEquals(len(logFiles), 2)
        self.assertIdentical(logFiles[1], sys.stdout)
开发者ID:P13RR3,项目名称:FrostCore,代码行数:17,代码来源:test_twistd.py


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