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


Python log.startLogging方法代码示例

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


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

示例1: run

# 需要导入模块: from twisted.python import log [as 别名]
# 或者: from twisted.python.log import startLogging [as 别名]
def run():
    log.startLogging(sys.stdout)

    if len(sys.argv) > 1 and sys.argv[1] == 'debug':
        debug = True
    else:
        debug = False

    # startup greeting
    #tts_say('Herzlich Willkommen')

    WEBSOCKET_URI = 'ws://localhost:9000'
    #WEBSOCKET_URI = 'ws://master.example.com:9000'
    boot_node(WEBSOCKET_URI, debug)

    reactor.run() 
开发者ID:daq-tools,项目名称:kotori,代码行数:18,代码来源:nodeservice.py

示例2: run

# 需要导入模块: from twisted.python import log [as 别名]
# 或者: from twisted.python.log import startLogging [as 别名]
def run():
#    import hotshot
#    prof = hotshot.Profile('cftp.prof')
#    prof.start()
    args = sys.argv[1:]
    if '-l' in args: # cvs is an idiot
        i = args.index('-l')
        args = args[i:i+2]+args
        del args[i+2:i+4]
    options = ClientOptions()
    try:
        options.parseOptions(args)
    except usage.UsageError as u:
        print('ERROR: %s' % u)
        sys.exit(1)
    if options['log']:
        realout = sys.stdout
        log.startLogging(sys.stderr)
        sys.stdout = realout
    else:
        log.discardLogs()
    doConnect(options)
    reactor.run()
#    prof.stop()
#    prof.close() 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:27,代码来源:cftp.py

示例3: test_printToStderrSetsIsError

# 需要导入模块: from twisted.python import log [as 别名]
# 或者: from twisted.python.log import startLogging [as 别名]
def test_printToStderrSetsIsError(self):
        """
        startLogging()'s overridden sys.stderr should consider everything
        written to it an error.
        """
        self._startLoggingCleanup()
        fakeFile = StringIO()
        log.startLogging(fakeFile)

        def observe(event):
            observed.append(event)
        observed = []
        log.addObserver(observe)

        print("Hello, world.", file=sys.stderr)
        self.assertEqual(observed[0]["isError"], 1) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:18,代码来源:test_log.py

示例4: test_startLogging

# 需要导入模块: from twisted.python import log [as 别名]
# 或者: from twisted.python.log import startLogging [as 别名]
def test_startLogging(self):
        """
        startLogging() installs FileLogObserver and overrides sys.stdout and
        sys.stderr.
        """
        origStdout, origStderr = sys.stdout, sys.stderr
        self._startLoggingCleanup()
        # When done with test, reset stdout and stderr to current values:
        fakeFile = StringIO()
        observer = log.startLogging(fakeFile)
        self.addCleanup(observer.stop)
        log.msg("Hello!")
        self.assertIn("Hello!", fakeFile.getvalue())
        self.assertIsInstance(sys.stdout, LoggingFile)
        self.assertEqual(sys.stdout.level, NewLogLevel.info)
        encoding = getattr(origStdout, "encoding", None)
        if not encoding:
            encoding = sys.getdefaultencoding()
        self.assertEqual(sys.stdout.encoding.upper(), encoding.upper())
        self.assertIsInstance(sys.stderr, LoggingFile)
        self.assertEqual(sys.stderr.level, NewLogLevel.error)
        encoding = getattr(origStderr, "encoding", None)
        if not encoding:
            encoding = sys.getdefaultencoding()
        self.assertEqual(sys.stderr.encoding.upper(), encoding.upper()) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:27,代码来源:test_log.py

示例5: test_startLoggingTwice

# 需要导入模块: from twisted.python import log [as 别名]
# 或者: from twisted.python.log import startLogging [as 别名]
def test_startLoggingTwice(self):
        """
        There are some obscure error conditions that can occur when logging is
        started twice. See http://twistedmatrix.com/trac/ticket/3289 for more
        information.
        """
        self._startLoggingCleanup()
        # The bug is particular to the way that the t.p.log 'global' function
        # handle stdout. If we use our own stream, the error doesn't occur. If
        # we use our own LogPublisher, the error doesn't occur.
        sys.stdout = StringIO()

        def showError(eventDict):
            if eventDict['isError']:
                sys.__stdout__.write(eventDict['failure'].getTraceback())

        log.addObserver(showError)
        self.addCleanup(log.removeObserver, showError)
        observer = log.startLogging(sys.stdout)
        self.addCleanup(observer.stop)
        # At this point, we expect that sys.stdout is a StdioOnnaStick object.
        self.assertIsInstance(sys.stdout, LoggingFile)
        fakeStdout = sys.stdout
        observer = log.startLogging(sys.stdout)
        self.assertIs(sys.stdout, fakeStdout) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:27,代码来源:test_log.py

示例6: test_startLoggingTwice

# 需要导入模块: from twisted.python import log [as 别名]
# 或者: from twisted.python.log import startLogging [as 别名]
def test_startLoggingTwice(self):
        """
        There are some obscure error conditions that can occur when logging is
        started twice. See http://twistedmatrix.com/trac/ticket/3289 for more
        information.
        """
        # The bug is particular to the way that the t.p.log 'global' function
        # handle stdout. If we use our own stream, the error doesn't occur. If
        # we use our own LogPublisher, the error doesn't occur.
        sys.stdout = StringIO()
        self.addCleanup(setattr, sys, 'stdout', sys.__stdout__)

        def showError(eventDict):
            if eventDict['isError']:
                sys.__stdout__.write(eventDict['failure'].getTraceback())

        log.addObserver(showError)
        self.addCleanup(log.removeObserver, showError)
        observer = log.startLogging(sys.stdout)
        self.addCleanup(observer.stop)
        # At this point, we expect that sys.stdout is a StdioOnnaStick object.
        self.assertIsInstance(sys.stdout, log.StdioOnnaStick)
        fakeStdout = sys.stdout
        observer = log.startLogging(sys.stdout)
        self.assertIdentical(sys.stdout, fakeStdout) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:27,代码来源:test_log.py

示例7: runApp

# 需要导入模块: from twisted.python import log [as 别名]
# 或者: from twisted.python.log import startLogging [as 别名]
def runApp(config):
    passphrase = app.getPassphrase(config['encrypted'])
    app.installReactor(config['reactor'])
    application = app.getApplication(config, passphrase)
    oldstdout = sys.stdout
    oldstderr = sys.stderr
    startLogging(config['logfile'])
    app.initialLog()
    os.chdir(config['rundir'])
    service.IService(application).privilegedStartService()
    app.startApplication(application, not config['no_save'])
    app.startApplication(internet.TimerService(0.1, lambda:None), 0)
    app.runReactorWithLogging(config, oldstdout, oldstderr)
    app.reportProfile(config['report-profile'],
                      service.IProcess(application).processName)
    log.msg("Server Shut Down.") 
开发者ID:kenorb-contrib,项目名称:BitTorrent,代码行数:18,代码来源:_twistw.py

示例8: startLogging

# 需要导入模块: from twisted.python import log [as 别名]
# 或者: from twisted.python.log import startLogging [as 别名]
def startLogging(logfilename, sysLog, prefix, nodaemon):
    if logfilename == '-':
        if not nodaemon:
            print 'daemons cannot log to stdout'
            os._exit(1)
        logFile = sys.stdout
    elif sysLog:
        syslog.startLogging(prefix)
    elif nodaemon and not logfilename:
        logFile = sys.stdout
    else:
        logFile = app.getLogFile(logfilename or 'twistd.log')
        try:
            import signal
        except ImportError:
            pass
        else:
            def rotateLog(signal, frame):
                from twisted.internet import reactor
                reactor.callFromThread(logFile.rotate)
            signal.signal(signal.SIGUSR1, rotateLog)
        
    if not sysLog:
        log.startLogging(logFile)
    sys.stdout.flush() 
开发者ID:kenorb-contrib,项目名称:BitTorrent,代码行数:27,代码来源:twistd.py

示例9: runApp

# 需要导入模块: from twisted.python import log [as 别名]
# 或者: from twisted.python.log import startLogging [as 别名]
def runApp(config):
    checkPID(config['pidfile'])
    passphrase = app.getPassphrase(config['encrypted'])
    app.installReactor(config['reactor'])
    config['nodaemon'] = config['nodaemon'] or config['debug']
    oldstdout = sys.stdout
    oldstderr = sys.stderr
    startLogging(config['logfile'], config['syslog'], config['prefix'],
                 config['nodaemon'])
    app.initialLog()
    application = app.getApplication(config, passphrase)
    startApplication(config, application)
    app.runReactorWithLogging(config, oldstdout, oldstderr)
    removePID(config['pidfile'])
    app.reportProfile(config['report-profile'],
                      service.IProcess(application).processName)
    log.msg("Server Shut Down.") 
开发者ID:kenorb-contrib,项目名称:BitTorrent,代码行数:19,代码来源:twistd.py

示例10: setup_wallets

# 需要导入模块: from twisted.python import log [as 别名]
# 或者: from twisted.python.log import startLogging [as 别名]
def setup_wallets():
    log.startLogging(sys.stdout)    
    load_coinswap_config()
    #need to give up waiting for confirms artificially quickly
    cs_single().one_confirm_timeout = 20
    cs_single().num_entities_running = 0 
开发者ID:AdamISZ,项目名称:CoinSwapCS,代码行数:8,代码来源:test_coinswap.py

示例11: ebConnection

# 需要导入模块: from twisted.python import log [as 别名]
# 或者: from twisted.python.log import startLogging [as 别名]
def ebConnection(reason):
    """
    Fallback error-handler. If anything goes wrong, log it and quit.
    """
    log.startLogging(sys.stdout)
    log.err(reason)
    return reason 
开发者ID:leapcode,项目名称:bitmask-dev,代码行数:9,代码来源:imapclient.py

示例12: run

# 需要导入模块: from twisted.python import log [as 别名]
# 或者: from twisted.python.log import startLogging [as 别名]
def run():

    if len(sys.argv) > 1 and sys.argv[1] == 'debug':
        log.startLogging(sys.stdout)
        debug = True
    else:
        debug = False

    websocket_uri = 'ws://localhost:9000'
    http_port = 35000

    boot_master(websocket_uri, http_port, debug)

    reactor.run() 
开发者ID:daq-tools,项目名称:kotori,代码行数:16,代码来源:server.py

示例13: run_wamp_client

# 需要导入模块: from twisted.python import log [as 别名]
# 或者: from twisted.python.log import startLogging [as 别名]
def run_wamp_client():
    log.startLogging(sys.stdout)
    runner = ApplicationRunner("ws://localhost:9000/ws", "kotori-realm")
    #runner = ApplicationRunner("ws://master.example.com:9000/ws", "kotori-realm")
    runner.run(KotoriClient, start_reactor=False)
    reactor.run() 
开发者ID:daq-tools,项目名称:kotori,代码行数:8,代码来源:client.py

示例14: run_udp_client

# 需要导入模块: from twisted.python import log [as 别名]
# 或者: from twisted.python.log import startLogging [as 别名]
def run_udp_client():
    log.startLogging(sys.stdout)

    #data = 'UDP hello'
    #data = '5;3;'
    try:
        data = sys.argv[1]
    except IndexError:
        data = ''

    sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
    sock.sendto(data, ('127.0.0.1', 7777)) 
开发者ID:daq-tools,项目名称:kotori,代码行数:15,代码来源:client.py

示例15: run_udp_fuzzer

# 需要导入模块: from twisted.python import log [as 别名]
# 或者: from twisted.python.log import startLogging [as 别名]
def run_udp_fuzzer():
    log.startLogging(sys.stdout)

    sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)

    while True:
        data = generate_packet()
        print 'packet:', data

        sock.sendto(data, ('127.0.0.1', 7777))
        time.sleep(0.25) 
开发者ID:daq-tools,项目名称:kotori,代码行数:14,代码来源:client.py


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