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


Python log.ILogObserver方法代码示例

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


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

示例1: setServiceParent

# 需要导入模块: from twisted.python import log [as 别名]
# 或者: from twisted.python.log import ILogObserver [as 别名]
def setServiceParent(self, app):
        MultiService.setServiceParent(self, app)

        if self.logEnabled:
            errorLogFile = LogFile.fromFullPath(
                self.logPath,
                rotateLength=self.logRotateLength,
                maxRotatedFiles=self.logMaxFiles
            )
            if self.logRotateOnStart:
                errorLogFile.rotate()
            encoding = "utf-8"
        else:
            errorLogFile = sys.stdout
            encoding = sys.stdout.encoding
        withTime = not (not config.ErrorLogFile and config.ProcessType in ("Slave", "DPS",))
        errorLogObserver = Logger.makeFilteredFileLogObserver(errorLogFile, withTime=withTime)

        # We need to do this because the current Twisted logger implementation fails to setup the encoding
        # correctly when a L{twisted.python.logile.LogFile} is passed to a {twisted.logger._file.FileLogObserver}
        errorLogObserver._observers[0]._encoding = encoding

        # Registering ILogObserver with the Application object
        # gets our observer picked up within AppLogger.start( )
        app.setComponent(ILogObserver, errorLogObserver) 
开发者ID:apple,项目名称:ccs-calendarserver,代码行数:27,代码来源:caldav.py

示例2: test_nonAsciiLog

# 需要导入模块: from twisted.python import log [as 别名]
# 或者: from twisted.python.log import ILogObserver [as 别名]
def test_nonAsciiLog(self):
        """
        Make sure that the file based error log can write non ascii data
        """

        logpath = self.mktemp()
        service = ErrorLoggingMultiService(
            True,
            logpath,
            10000,
            10,
            False,
        )
        app = Application("non-ascii")
        service.setServiceParent(app)

        observer = app.getComponent(ILogObserver, None)
        self.assertTrue(observer is not None)

        log = Logger(observer=observer)
        log.error(u"Couldn\u2019t be wrong")

        with open(logpath) as f:
            logentry = f.read()
        self.assertIn("Couldn\xe2\x80\x99t be wrong", logentry) 
开发者ID:apple,项目名称:ccs-calendarserver,代码行数:27,代码来源:test_caldav.py

示例3: start

# 需要导入模块: from twisted.python import log [as 别名]
# 或者: from twisted.python.log import ILogObserver [as 别名]
def start(self, application):
        """
        Initialize the logging system.

        If an L{ILogObserver} component has been set on C{application}, then
        it will be used as the log observer.  Otherwise a log observer will be
        created based on the command-line options.

        @param application: The application on which to check for an
            L{ILogObserver}.
        """
        observer = application.getComponent(ILogObserver, None)

        if observer is None:
            observer = self._getLogObserver()
        self._observer = observer
        log.startLoggingWithObserver(self._observer)
        self._initialLog() 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:20,代码来源:app.py

示例4: CanvasApp

# 需要导入模块: from twisted.python import log [as 别名]
# 或者: from twisted.python.log import ILogObserver [as 别名]
def CanvasApp(nginx=False):
    application = service.Application("Canvas")

    web_server = CanvasTCPServer()
    web_server.setServiceParent(application)
    
    
    log_file = logfile.LogFile(
        name="twistd.log", 
        directory="/var/canvas/website/run",
        maxRotatedFiles=100,
    )
    
    application.setComponent(log.ILogObserver, log.FileLogObserver(log_file).emit)

    return application 
开发者ID:canvasnetworks,项目名称:canvas,代码行数:18,代码来源:server.py

示例5: setServiceParent

# 需要导入模块: from twisted.python import log [as 别名]
# 或者: from twisted.python.log import ILogObserver [as 别名]
def setServiceParent(self, parent):
        service.MultiService.setServiceParent(self, parent)
        if isinstance(parent, Componentized):
            parent.setComponent(ILogObserver, rurouniLogObserver) 
开发者ID:douban,项目名称:Kenshin,代码行数:6,代码来源:service.py

示例6: test_startUsesApplicationLogObserver

# 需要导入模块: from twisted.python import log [as 别名]
# 或者: from twisted.python.log import ILogObserver [as 别名]
def test_startUsesApplicationLogObserver(self):
        """
        When the L{ILogObserver} component is available on the application,
        that object will be used as the log observer instead of constructing a
        new one.
        """
        application = Componentized()
        logs = []
        application.setComponent(ILogObserver, logs.append)
        logger = app.AppLogger({})
        logger.start(application)
        self._checkObserver(logs) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:14,代码来源:test_twistd.py

示例7: start

# 需要导入模块: from twisted.python import log [as 别名]
# 或者: from twisted.python.log import ILogObserver [as 别名]
def start(self, application):
        """
        Initialize the global logging system for the given application.

        If a custom logger was specified on the command line it will be used.
        If not, and an L{logger.ILogObserver} or legacy L{log.ILogObserver}
        component has been set on C{application}, then it will be used as the
        log observer. Otherwise a log observer will be created based on the
        command line options for built-in loggers (e.g. C{--logfile}).

        @param application: The application on which to check for an
            L{logger.ILogObserver} or legacy L{log.ILogObserver}.
        @type application: L{twisted.python.components.Componentized}
        """
        if self._observerFactory is not None:
            observer = self._observerFactory()
        else:
            observer = application.getComponent(logger.ILogObserver, None)
            if observer is None:
                # If there's no new ILogObserver, try the legacy one
                observer = application.getComponent(log.ILogObserver, None)

        if observer is None:
            observer = self._getLogObserver()
        self._observer = observer

        if logger.ILogObserver.providedBy(self._observer):
            observers = [self._observer]
        elif log.ILogObserver.providedBy(self._observer):
            observers = [logger.LegacyLogObserverWrapper(self._observer)]
        else:
            warnings.warn(
                ("Passing a logger factory which makes log observers which do "
                 "not implement twisted.logger.ILogObserver or "
                 "twisted.python.log.ILogObserver to "
                 "twisted.application.app.AppLogger was deprecated in "
                 "Twisted 16.2. Please use a factory that produces "
                 "twisted.logger.ILogObserver (or the legacy "
                 "twisted.python.log.ILogObserver) implementing objects "
                 "instead."),
                DeprecationWarning,
                stacklevel=2)
            observers = [logger.LegacyLogObserverWrapper(self._observer)]

        logger.globalLogBeginner.beginLoggingTo(observers)
        self._initialLog() 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:48,代码来源:app.py


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