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


Python log.startLoggingWithObserver方法代码示例

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


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

示例1: start

# 需要导入模块: from twisted.python import log [as 别名]
# 或者: from twisted.python.log import startLoggingWithObserver [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

示例2: _startLoggingWithObserver

# 需要导入模块: from twisted.python import log [as 别名]
# 或者: from twisted.python.log import startLoggingWithObserver [as 别名]
def _startLoggingWithObserver(observer, setStdout=1):
    """Replacement for `t.p.log.startLoggingWithObserver`.

    When `twistd` starts in 16.0 it initialises the legacy logging system.
    Intercept this to DTRT with either a modern or legacy observer.

    In Xenial (with Twisted 16.0) `observer` is probably a legacy observer,
    like twisted.python.log.FileLogObserver, but we should check if it's
    modern. In either case we should call through to the `globalLogBeginner`
    ourselves. In Yakkety (with Twisted 16.4) this function will not be
    called; `t.application.app.AppLogger` does the right thing already.
    """
    if not twistedModern.ILogObserver.providedBy(observer):
        observer = twistedModern.LegacyLogObserverWrapper(observer)
    twistedModern.globalLogBeginner.beginLoggingTo(
        [observer], discardBuffer=False, redirectStandardIO=bool(setStdout)
    ) 
开发者ID:maas,项目名称:maas,代码行数:19,代码来源:_twisted.py

示例3: carml

# 需要导入模块: from twisted.python import log [as 别名]
# 或者: from twisted.python.log import startLoggingWithObserver [as 别名]
def carml(ctx, timestamps, no_color, info, quiet, debug, debug_protocol, password, connect, color, json):
    if (color == 'always' and no_color) or \
       (color == 'no' and no_color is True):
        raise click.UsageError(
            "--no-color={} but --color={}".format(no_color, color)
        )

    cfg = Config()
    ctx.obj = cfg

    cfg.timestamps = timestamps
    cfg.no_color = no_color
    cfg.info = info
    cfg.quiet = quiet
    cfg.debug = debug
    cfg.password = password
    cfg.connect = connect
    cfg.color = color
    cfg.debug_protocol = debug_protocol
    cfg.json = True if json else False

    # start logging
    _log_observer = LogObserver()
    log.startLoggingWithObserver(_log_observer, setStdout=False) 
开发者ID:meejah,项目名称:carml,代码行数:26,代码来源:cli.py

示例4: startLogging

# 需要导入模块: from twisted.python import log [as 别名]
# 或者: from twisted.python.log import startLoggingWithObserver [as 别名]
def startLogging(self, filePath=None, stealStdio=False, printToConsole=True):
        '''
        Begin logging. The output class is ready to go out of the box, but in order
        to prevent mere imports from stealing stdio or console logging to vanish
        these must be manually turned on.

        :param filePath: if provided, begin logging to the given directory. If
            not provided, do not write out logs.
        :type filePath: str
        :param stealStdio: choose to intercept stdio (including vanilla print
            statements) or allow it to passthrough
        :type stealStdio: bool.
        :param printToConsole: output the results of all logging to the console. This
            is primarily a performance consideration when running in production
        :type printToConsole: bool.

        '''

        # Initialize printer thread
        self.__dict__['logpath'] = None

        if filePath is not None:
            self.__dict__['queue'] = queue.Queue()
            self.__dict__['printer'] = PrintLogThread(filePath, self.queue, LOG_NAME)
            self.__dict__['logpath'] = filePath
            self.printer.start()

        # by default, stdio gets captures. This can be toggled off
        self.stealStdio(stealStdio)
        self.logToConsole(printToConsole)

        # Override twisted logging (allows us to cleanly catch all exceptions)
        # This must come after the setattr calls so we get the wrapped object
        log.startLoggingWithObserver(self.twisted, setStdout=False)
        log.startLoggingWithObserver(self.twistedErr, setStdout=False) 
开发者ID:ParadropLabs,项目名称:Paradrop,代码行数:37,代码来源:output.py

示例5: _setUpLogFile

# 需要导入模块: from twisted.python import log [as 别名]
# 或者: from twisted.python.log import startLoggingWithObserver [as 别名]
def _setUpLogFile(self):
        self._tearDownLogFile()
        if self.logfile == '-':
            logFile = sys.stdout
        else:
            logFile = open(self.logfile, 'a')
        self._logFileObject = logFile
        self._logFileObserver = log.FileLogObserver(logFile)
        log.startLoggingWithObserver(self._logFileObserver.emit, 0) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:11,代码来源:runner.py

示例6: startLogging

# 需要导入模块: from twisted.python import log [as 别名]
# 或者: from twisted.python.log import startLoggingWithObserver [as 别名]
def startLogging(prefix='Twisted', options=DEFAULT_OPTIONS,
                 facility=DEFAULT_FACILITY, setStdout=1):
    """
    Send all Twisted logging output to syslog from now on.

    The prefix, options and facility arguments are passed to
    C{syslog.openlog()}, see the Python syslog documentation for details. For
    other parameters, see L{twisted.python.log.startLoggingWithObserver}.
    """
    obs = SyslogObserver(prefix, options, facility)
    log.startLoggingWithObserver(obs.emit, setStdout=setStdout) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:13,代码来源:syslog.py

示例7: _setUpLogFile

# 需要导入模块: from twisted.python import log [as 别名]
# 或者: from twisted.python.log import startLoggingWithObserver [as 别名]
def _setUpLogFile(self):
        self._tearDownLogFile()
        if self.logfile == '-':
            logFile = sys.stdout
        else:
            logFile = file(self.logfile, 'a')
        self._logFileObject = logFile
        self._logFileObserver = log.FileLogObserver(logFile)
        log.startLoggingWithObserver(self._logFileObserver.emit, 0) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:11,代码来源:runner.py

示例8: start

# 需要导入模块: from twisted.python import log [as 别名]
# 或者: from twisted.python.log import startLoggingWithObserver [as 别名]
def start(error_log_level = logging.ERROR,
          info_log_level = logging.INFO ):
    """Writes twisted output to a logger using 'twisted' as the
       logger name (i.e., 'twisted' is passed as name arg to logging.getLogger(name)).
       """
    o = LogLogObserver(error_log_level, info_log_level)

    # We do not use twisted setStdout logging because it is not clear to me
    # how to differentiate twisted-generated log entries and
    # redirected output.  It is possible that all stdout and stderr
    # output has system '-', but from looking at twisted source code
    # there does not appear to be any guarantee that this is the case.
    # A simpler way of handling this is to simply separate
    # stdio and stderr redirection from twisted logging.   --Dave
    log.startLoggingWithObserver(o.emit , setStdout = 0) #setStdout=int(capture_output)) 
开发者ID:kenorb-contrib,项目名称:BitTorrent,代码行数:17,代码来源:twisted_logger.py

示例9: __init__

# 需要导入模块: from twisted.python import log [as 别名]
# 或者: from twisted.python.log import startLoggingWithObserver [as 别名]
def __init__(self, timestamp=False, flush=True):
        self.timestamp = timestamp
        self.flush = flush
        # we keep our own copies of these, because Twisted's
        # startLoggingWithObserver overwrites them with its own
        # monitoring machinery
        self.stdout = sys.stdout
        self.stderr = sys.stderr 
开发者ID:meejah,项目名称:carml,代码行数:10,代码来源:cli.py


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