• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python logfile.DailyLogFile类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: start_logging

 def start_logging(self):
     """Starts logging to log file or stdout depending on config."""
     if self.use_log:
         if self.log_stdout:
             log.startLogging(sys.stdout)
         else:
             log_file = os.path.expanduser(self.log_file)
             log.startLogging(DailyLogFile.fromFullPath(log_file))
开发者ID:maelick,项目名称:Clipsync,代码行数:8,代码来源:clipsync.py


示例17: logToDir

def logToDir(directory='logs', LOG_TYPE=('console',), OBSERVER=MyLogObserver):
    """Call this to write logs to the specified directory,
       optionally override the FileLogObserver.
    """
    for name in LOG_TYPE:
        path = os.path.join(directory, name + '.log')
        logfile = DailyLogFile.fromFullPath(path)
        logs[name] = OBSERVER(logfile)
开发者ID:cbrinley,项目名称:droned,代码行数:8,代码来源:logging.py


示例18: _handle_logging

    def _handle_logging(self):
        """
        Start logging to file if there is some file configuration and we
        are not running in development mode
        """

        if self.development is False and self._log_file is not None:
            self.already_logging = True
            log.startLogging(DailyLogFile.fromFullPath(self.log_file))
开发者ID:DamnWidget,项目名称:mamba,代码行数:9,代码来源:app.py


示例19: initLog

def initLog(log_file, log_path, loglevel=0):
    global log_level, _tracemsg
    log_level = loglevel
    fout = DailyLogFile(log_file, log_path)
    if _tracemsg :
        for msg in _tracemsg :
            fout.write(msg)
            fout.write('\n')
        _tracemsg = None

    class _(log.FileLogObserver):
        log.FileLogObserver.timeFormat = '%m-%d %H:%M:%S.%f'
        def emit(self, eventDict):
            taskinfo = "%r" % stackless.getcurrent() 
            eventDict['system'] = taskinfo[9:-2]   
            log.FileLogObserver.emit(self, eventDict)
    fl = _(fout)
    log.startLoggingWithObserver(fl.emit)
开发者ID:zhaozw,项目名称:hall37,代码行数:18,代码来源:tylog.py


示例20: 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)
    log.msg("Open files limit: %d" % resource.getrlimit(resource.RLIMIT_NOFILE)[0])
开发者ID:netconstructor,项目名称:splash,代码行数:9,代码来源:server.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python logfile.LogFile类代码示例发布时间:2022-05-27
下一篇:
Python log.textFromEventDict函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap