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


Python LogFile.flush方法代码示例

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


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

示例1: DummyLogFile

# 需要导入模块: from twisted.python.logfile import LogFile [as 别名]
# 或者: from twisted.python.logfile.LogFile import flush [as 别名]
class DummyLogFile(object):
    '''Dummy log file used for testing.'''
    def __init__(
            self, worker_id, directory, rotateLength, maxRotatedFiles):
        self.worker_id = worker_id
        self.directory = directory
        self.rotateLength = rotateLength
        self.maxRotatedFiles = maxRotatedFiles
        self.closed_count = 0
        self.logfile = LogFile(
            worker_id, directory, rotateLength=rotateLength,
            maxRotatedFiles=maxRotatedFiles)
        self.path = self.logfile.path

    @property
    def logs(self):
        reader = self.logfile.getCurrentLog()
        logs = []
        lines = reader.readLines()
        while lines:
            logs.extend(lines)
            lines = reader.readLines()
        return logs

    def write(self, data):
        self.logfile.write(data)
        self.logfile.flush()

    def close(self):
        self.closed_count += 1

    def listLogs(self):
        return []
开发者ID:praekelt,项目名称:junebug,代码行数:35,代码来源:helpers.py

示例2: emmit

# 需要导入模块: from twisted.python.logfile import LogFile [as 别名]
# 或者: from twisted.python.logfile.LogFile import flush [as 别名]
 def emmit(self, event):
     if event.get("isDebug", False) and is_production():
         return  # Don't log debug messages in production.
     location, prefix, log_time, log_time_str, entry_text = self.parse_from(event)
     folder, name = build_file(self.folder, location, self.extension)
     try:
         log = LogFile(name, folder)
         log.write("%s %s\n\t%s\n" % (prefix, log_time_str, entry_text.replace("\n", "\n\t\t")))
         log.flush()
         log.close()
     finally:
         if event.get("transmit", False) and not event.get("isDebug", False):
             self.service.write_entry(location, log_time, entry_text)
开发者ID:leesdolphin,项目名称:eventstreamr,代码行数:15,代码来源:logging.py

示例3: receive_logs

# 需要导入模块: from twisted.python.logfile import LogFile [as 别名]
# 或者: from twisted.python.logfile.LogFile import flush [as 别名]
    def receive_logs(self, logs, transport):
        client_mac = self.__stations[transport.client].mac;
        client_mac = client_mac.translate(None, ":|/\\")
        files = {}
        for time, location, msg in logs:
            if location in files:
                log_file = files[location]
            else:
                loc = [client_mac] + list(location)
                folder, name = build_file(self.__output_folder, loc, self.__extension)
                log_file = LogFile(name, folder)
                files[location] = log_file
            log_time_str = strftime("%Y-%m-%d %H:%M:%S:%f", gmtime(time))
            log_file.write(">%s\n\t%s\n" % (log_time_str, msg.replace("\n", "\n\t\t")))

        # Now close those files
        for log_file in files.itervalues():
            log_file.flush()
            log_file.close()
        return {"accepted": True}
开发者ID:leesdolphin,项目名称:eventstreamr,代码行数:22,代码来源:station_logs.py


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