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


Python logfile.DailyLogFile类代码示例

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


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

示例1: rotate

    def rotate(self):
        """Rotate the current logfile.

        Also remove extra entries and compress the last ones.
        """
        # Rotate the log daily.
        DailyLogFile.rotate(self)

        # Remove 'extra' rotated log files.
        logs = self.listLogs()
        for log_path in logs[self.maxRotatedFiles:]:
            os.remove(log_path)

        # Refresh the list of existing rotated logs
        logs = self.listLogs()

        # Skip compressing if there are no files to be compressed.
        if len(logs) <= self.compressLast:
            return

        # Compress last log files.
        for log_path in logs[-self.compressLast:]:
            # Skip already compressed files.
            if log_path.endswith('bz2'):
                continue
            self._compressFile(log_path)
开发者ID:pombreda,项目名称:UnnaturalCodeFork,代码行数:26,代码来源:loggingsupport.py

示例2: rotate

 def rotate(self):
     DailyLogFile.rotate(self)
     dir = os.path.dirname(self.path)
     files = os.listdir(dir)
     for file in files:
         if file.startswith("honeypy.log."):
             os.remove(os.path.join(dir, file))
开发者ID:foospidy,项目名称:HoneyPy,代码行数:7,代码来源:honeypy_logtail.py

示例3: PrintLogThread

class PrintLogThread(threading.Thread):

    '''
    All file printing access from one thread.

    Receives information when its placed on the passed queue.
    Called from one location: Output.handlePrint.

    Does not close the file: this happens in Output.endLogging. This
    simplifies the operation of this class, since it only has to concern
    itself with the queue.

    The path must exist before DailyLog runs for the first time.
    '''

    def __init__(self, path, queue, name):
        threading.Thread.__init__(self)
        self.queue = queue
        self.writer = DailyLogFile(name, path)

        # Don't want this to float around if the rest of the system goes down
        self.setDaemon(True)

    def run(self):
        while True:
            result = self.queue.get(block=True)

            try:
                writable = json.dumps(result)
                self.writer.write(writable + '\n')
                self.writer.flush()
            except:
                pass

            self.queue.task_done()
开发者ID:ParadropLabs,项目名称:Paradrop,代码行数:35,代码来源:output.py

示例4: makeService

def makeService(_config):
    global config
    config = _config

    if config['logpath'] != None:
        logFilePath = os.path.abspath(config['logpath'])
        logFile = DailyLogFile.fromFullPath(logFilePath)
    else:
        logFile = sys.stdout

    log.startLogging(logFile)

    lumenService = service.MultiService()

    # Bayeux Service
    import bayeux
    bayeuxFactory = bayeux.BayeuxServerFactory()
    bayeuxService = internet.TCPServer(config['port'], bayeuxFactory)
    bayeuxService.setServiceParent(lumenService)

    # WebConsole Service
    import webconsole
    site = server.Site(webconsole.WebConsole())
    webConsoleService = internet.TCPServer(config['webport'], site)
    webConsoleService.setServiceParent(lumenService)

    application = service.Application("lumen")
    lumenService.setServiceParent(application)

    return lumenService
开发者ID:unsouled,项目名称:lumen,代码行数:30,代码来源:lumen.py

示例5: write

 def write(self, data):
   if not self.enableRotation:
     if not os.path.exists(self.path):
       self.reopen()
     else:
       path_stat = os.stat(self.path)
       fd_stat = os.fstat(self._file.fileno())
       if not (path_stat.st_ino == fd_stat.st_ino and path_stat.st_dev == fd_stat.st_dev):
         self.reopen()
   DailyLogFile.write(self, data)
开发者ID:graphite-project,项目名称:carbon,代码行数:10,代码来源:log.py

示例6: __init__

    def __init__(self, name, directory, defaultMode=None,
                 maxRotatedFiles=None, compressLast=None):
        DailyLogFile.__init__(self, name, directory, defaultMode)
        if maxRotatedFiles is not None:
            self.maxRotatedFiles = int(maxRotatedFiles)
        if compressLast is not None:
            self.compressLast = int(compressLast)

        assert self.compressLast <= self.maxRotatedFiles, (
            "Only %d rotate files are kept, cannot compress %d"
            % (self.maxRotatedFiles, self.compressLast))
开发者ID:pombreda,项目名称:UnnaturalCodeFork,代码行数:11,代码来源:loggingsupport.py

示例7: init_logging

def init_logging(logdir, logname):
    if DEBUG_LEVEL > 0:
        log.startLogging(sys.stdout)
    if not os.path.exists(logdir):
        os.makedirs(logdir)
    logfile = get_path(os.path.join(logdir, logname))
    log.startLogging(DailyLogFile.fromFullPath(logfile))
开发者ID:hosle,项目名称:tapas,代码行数:7,代码来源:util.py

示例8: noiseControl

def noiseControl(options):
    # terminal noise/info logic
    # allows the specification of the log file location
    if not options["loud"]:
        log_path = options["log"]
        log.startLogging(DailyLogFile.fromFullPath(log_path))
    return None
开发者ID:dmpayton,项目名称:hendrix,代码行数:7,代码来源:ux.py

示例9: make_logfile_observer

def make_logfile_observer(path, show_source=False):
    """
    Make an observer that writes out to C{path}.
    """
    from twisted.logger import FileLogObserver
    from twisted.python.logfile import DailyLogFile

    f = DailyLogFile.fromFullPath(path)

    def _render(event):

        if event.get("log_system", u"-") == u"-":
            logSystem = u"{:<10} {:>6}".format("Controller", os.getpid())
        else:
            logSystem = event["log_system"]

        if show_source and event.get("log_namespace") is not None:
            logSystem += " " + event.get("cb_namespace", event.get("log_namespace", ''))

        if event.get("log_format", None) is not None:
            eventText = formatEvent(event)
        else:
            eventText = ""

        if "log_failure" in event:
            # This is a traceback. Print it.
            eventText = eventText + event["log_failure"].getTraceback()

        eventString = NOCOLOUR_FORMAT.format(
            formatTime(event["log_time"]), logSystem, eventText) + os.linesep

        return eventString

    return FileLogObserver(f, _render)
开发者ID:yatskevich,项目名称:crossbar,代码行数:34,代码来源:_logging.py

示例10: __init__

	def __init__(self):
		try:
			logfile = DailyLogFile.fromFullPath(cfg.logging.filename)
		except AssertionError:
			raise AssertionError("Assertion error attempting to open the log file: {0}. Does the directory exist?".format(cfg.logging.filename))

		twistedlogger.startLogging(logfile, setStdout=False)
开发者ID:Urthen,项目名称:Fritbot_Python,代码行数:7,代码来源:audit.py

示例11: _createLogFile

    def _createLogFile(self, uuid):
        logDirPath = '{cwd}\\..\\logs\\aiprocesses'.format(cwd=os.getcwd())
        if not os.path.exists(logDirPath):
            os.mkdir(logDirPath)

        logFilePath = '{dir}\\{uuid}.log'.format(dir=logDirPath, uuid=uuid)
        log.startLogging(DailyLogFile.fromFullPath(logFilePath))
开发者ID:FlorinLozneanu,项目名称:tictactoe,代码行数:7,代码来源:aiprocess.py

示例12: run_normal

 def run_normal(self):
     if self.debug:
         log.startLogging(sys.stdout)
     else:
         log.startLogging(DailyLogFile.fromFullPath(self.logfile))
     log.msg("portal server listen %s" % self.portal_host)
     reactor.listenUDP(self.listen_port, self, interface=self.portal_host)
开发者ID:simudream,项目名称:toughportal,代码行数:7,代码来源:cmcc_server.py

示例13: __init__

    def __init__(self, path, queue, name):
        threading.Thread.__init__(self)
        self.queue = queue
        self.writer = DailyLogFile(name, path)

        # Don't want this to float around if the rest of the system goes down
        self.setDaemon(True)
开发者ID:ParadropLabs,项目名称:Paradrop,代码行数:7,代码来源:output.py

示例14: start_logging

def start_logging(opts):
    from twisted.python import log
    from twisted.python.logfile import DailyLogFile
    if opts.logfile:
        logfile = DailyLogFile.fromFullPath(opts.logfile)
    else:
        logfile = sys.stderr
    log.startLogging(logfile)
开发者ID:andresp99999,项目名称:splash,代码行数:8,代码来源:server.py

示例15: __init__

    def __init__(self, *args, **kwargs):
        """
        Create a log file rotating on length.

        @param name: file name.
        @type name: C{str}
        @param directory: path of the log file.
        @type directory: C{str}
        @param defaultMode: mode used to create the file.
        @type defaultMode: C{int}
        @param maxRotatedFiles: if not None, max number of log files the class
            creates. Warning: it removes all log files above this number.
        @type maxRotatedFiles: C{int}
        """
        self.maxRotatedFiles = kwargs.pop('maxRotatedFiles', None)
        DailyLogFile.__init__(self, *args, **kwargs)
        self._logger = logWithContext(type='console')
开发者ID:OrbitzWorldwide,项目名称:droned,代码行数:17,代码来源:logging.py


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