Exemple #1
0
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()
Exemple #2
0
def startLogging(logfilename):
    if logfilename == '-' or not logfilename:
        logFile = sys.stdout
    else:
        logFile = app.getLogFile(logfilename)
    log.startLogging(logFile)
    sys.stdout.flush()
 def test_getLogFile(self):
     os.mkdir("logfiledir")
     l = app.getLogFile(os.path.join("logfiledir", "lala"))
     self.assertEqual(l.path,
                      os.path.abspath(os.path.join("logfiledir", "lala")))
     self.assertEqual(l.name, "lala")
     self.assertEqual(l.directory, os.path.abspath("logfiledir"))
 def test_getLogFile(self):
     os.mkdir("logfiledir")
     l = app.getLogFile(os.path.join("logfiledir", "lala"))
     self.assertEqual(l.path,
                      os.path.abspath(os.path.join("logfiledir", "lala")))
     self.assertEqual(l.name, "lala")
     self.assertEqual(l.directory, os.path.abspath("logfiledir"))
Exemple #5
0
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()
Exemple #6
0
def startLogging(logfilename):
    if logfilename == '-' or not logfilename:
        logFile = sys.stdout
    else:
        logFile = app.getLogFile(logfilename)
    log.startLogging(logFile)
    sys.stdout.flush()
Exemple #7
0
 def test_getLogFile(self):
     """
     Test L{app.getLogFile}, veryfying the LogFile instance it returns.
     """
     os.mkdir("logfiledir")
     l = app.getLogFile(os.path.join("logfiledir", "lala"))
     self.assertEqual(l.path,
                      os.path.abspath(os.path.join("logfiledir", "lala")))
     self.assertEqual(l.name, "lala")
     self.assertEqual(l.directory, os.path.abspath("logfiledir"))
 def test_getLogFile(self):
     """
     Test L{app.getLogFile}, veryfying the LogFile instance it returns.
     """
     os.mkdir("logfiledir")
     l = app.getLogFile(os.path.join("logfiledir", "lala"))
     self.assertEqual(l.path,
                      os.path.abspath(os.path.join("logfiledir", "lala")))
     self.assertEqual(l.name, "lala")
     self.assertEqual(l.directory, os.path.abspath("logfiledir"))