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

Python logfile.LogFile类代码示例

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

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



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

示例1: DummyLogFile

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,代码行数:33,代码来源:helpers.py


示例2: __init__

 def __init__(self, name,group):
   self.orgName = name
   self.name = "".join([x for x in name if x.isalnum()])
   self.group = group
   self.logFile = LogFile(self.name+".log",group.groupDir,rotateLength=100000000,maxRotatedFiles=10)#10M
   self.updateLogFile = LogFile(self.name+".ulog",group.groupDir,rotateLength=100000000,maxRotatedFiles=5)
   self.ssLogFile = LogFile(self.name+".slog",group.groupDir,rotateLength=100000000,maxRotatedFiles=5)
   self.status = PROC_STATUS.STOP
   self.endTime = None
   self.startMemo = ''
开发者ID:fordguo,项目名称:stdpm,代码行数:10,代码来源:process.py


示例3: startService

 def startService(self):
     self.logfile = LogFile(
         self.worker_id, self.path, rotateLength=self.rotate,
         maxRotatedFiles=self.max_files)
     self.log_observer = JunebugLogObserver(self.logfile, self.worker_id)
     self.logger.addObserver(self.log_observer)
     return super(JunebugLoggerService, self).startService()
开发者ID:grigi,项目名称:junebug,代码行数:7,代码来源:logging_service.py


示例4: __init__

 def __init__(
         self, worker_id, path, rotateLength, maxRotatedFiles):
     self.worker_id = worker_id
     self.path = path
     self.rotateLength = rotateLength
     self.maxRotatedFiles = maxRotatedFiles
     self.closed_count = 0
     self.logfile = LogFile.fromFullPath(
         path, rotateLength=rotateLength, maxRotatedFiles=maxRotatedFiles)
开发者ID:BantouTelecom,项目名称:junebug,代码行数:9,代码来源:helpers.py


示例5: startService

 def startService(self):
     if not os.path.exists(self.path):
         os.makedirs(self.path, 0755)
     self.logfile = LogFile(
         self.worker_id, self.path, rotateLength=self.rotate,
         maxRotatedFiles=self.max_files)
     self.log_observer = JunebugLogObserver(self.logfile, self.worker_id)
     self.logger.addObserver(self.log_observer)
     return super(JunebugLoggerService, self).startService()
开发者ID:praekelt,项目名称:junebug,代码行数:9,代码来源:logging_service.py


示例6: __init__

    def __init__(self, nick, server, channel, port, loggingfile=None):
        self.server = server
        self.port = port

        if loggingfile is not None:
            log.startLogging(LogFile.fromFullPath(loggingfile))
        self.factory = ConversationBotFactory(self, ConversationBotClient,
                                              nick,
                                              channel)
开发者ID:trew,项目名称:conversationbot,代码行数:9,代码来源:ConversationBot.py


示例7: JunebugLoggerService

class JunebugLoggerService(Service):
    '''Service for :class:`junebug.logging.JunebugLogObserver`'''
    log_observer = None

    def __init__(self, worker_id, path, rotate, max_files, logger=None):
        '''
        Create the service for the Junebug Log Observer.

        :param str worker_id: ID of the worker to observe logs for.
        :param str path: Path to place the log files.
        :param int rotate: Size (in bytes) before rotating log file.
        :param int max_files:
            Maximum amount of log files before old log files
            start to get deleted.
        :param logger:
            logger to add observer to. Defaults to
            twisted.python.log.theLogPublisher
        :type logger: :class:`twisted.python.log.LogPublisher`
        '''
        self.setName('Junebug Worker Logger')
        self.logger = logger if logger is not None else log.theLogPublisher
        self.worker_id = worker_id
        self.path = path
        self.rotate = rotate
        self.max_files = max_files

    def startService(self):
        if not os.path.exists(self.path):
            os.makedirs(self.path, 0755)
        self.logfile = LogFile(
            self.worker_id, self.path, rotateLength=self.rotate,
            maxRotatedFiles=self.max_files)
        self.log_observer = JunebugLogObserver(self.logfile, self.worker_id)
        self.logger.addObserver(self.log_observer)
        return super(JunebugLoggerService, self).startService()

    def stopService(self):
        if self.running:
            self.logger.removeObserver(self.log_observer)
            self.logfile.close()
        return super(JunebugLoggerService, self).stopService()

    def registered(self):
        return self.log_observer in self.logger.observers
开发者ID:praekelt,项目名称:junebug,代码行数:44,代码来源:logging_service.py


示例8: _openLogFile

 def _openLogFile(self, path):
     try:
         from twisted.python.logfile import LogFile
         log.msg("Setting up http.log rotating %s files of %s bytes each" %
                 (maxRotatedFiles, rotateLength))
         if hasattr(LogFile, "fromFullPath"):  # not present in Twisted-2.5.0
             return LogFile.fromFullPath(path, rotateLength=rotateLength, maxRotatedFiles=maxRotatedFiles)
         else:
             log.msg("WebStatus: rotated http logs are not supported on this version of Twisted")
     except ImportError, e:
         log.msg("WebStatus: Unable to set up rotating http.log: %s" % e)
开发者ID:bshawk,项目名称:buildbot,代码行数:11,代码来源:service.py


示例9: startService

 def startService(self):
     Service.startService(self)
     if self.filename != '-':
         self.logfile = LogFile.fromFullPath(
             self.filename, rotateLength=None, defaultMode=0o644)
         self.__previous_signal_handler = signal.signal(
             signal.SIGUSR1, self._signal_handler)
     else:
         self.logfile = sys.stdout
     self.observer = FileLogObserver(self.logfile)
     self.observer.start()
开发者ID:CanonicalLtd,项目名称:txlongpoll,代码行数:11,代码来源:services.py


示例10: __init__

 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
开发者ID:praekelt,项目名称:junebug,代码行数:11,代码来源:helpers.py


示例11: __init__

 def __init__(self, logfilename):
     if logfilename is None:
         logFile = sys.stdout
     else:
         logFile = LogFile.fromFullPath(logfilename, rotateLength=None)
         # Override if signal is set to None or SIG_DFL (0)
         if not signal.getsignal(signal.SIGUSR1):
             def signalHandler(signal, frame):
                 from twisted.internet import reactor
                 reactor.callFromThread(logFile.reopen)
             signal.signal(signal.SIGUSR1, signalHandler)
     self.observer = log.FileLogObserver(logFile)
开发者ID:arjan,项目名称:sparked,代码行数:12,代码来源:tap.py


示例12: setup_logging

def setup_logging():
    filename = LOG_SETTINGS['file_path']
    log_file = LogFile.fromFullPath(
        filename,
        rotateLength=LOG_SETTINGS['max_bytes'],
        maxRotatedFiles=LOG_SETTINGS['max_backups']
    ) if filename is not None else sys.stdout

    log_level = getattr(logging, LOG_SETTINGS['level'])

    observer = LevelFileLogObserver(log_file, log_level)
    observer.timeFormat = LOG_SETTINGS['time_format']
    observer.start()
开发者ID:IL2HorusTeam,项目名称:minic,代码行数:13,代码来源:application.py


示例13: opt_logfile

 def opt_logfile(self, logfile_path):
     """
     Log to a file. Log is written to ``stdout`` by default. The logfile
     directory is created if it does not already exist.
     """
     logfile = FilePath(logfile_path)
     logfile_directory = logfile.parent()
     if not logfile_directory.exists():
         logfile_directory.makedirs()
     self['logfile'] = LogFile.fromFullPath(
         logfile.path,
         rotateLength=LOGFILE_LENGTH,
         maxRotatedFiles=LOGFILE_COUNT,
     )
开发者ID:Azulinho,项目名称:flocker,代码行数:14,代码来源:script.py


示例14: setServiceParent

    def setServiceParent(self, app):
        MultiService.setServiceParent(self, app)

        if config.ErrorLogEnabled:
            errorLogFile = LogFile.fromFullPath(
                config.ErrorLogFile,
                rotateLength=config.ErrorLogRotateMB * 1024 * 1024,
                maxRotatedFiles=config.ErrorLogMaxRotatedFiles
            )
            errorLogObserver = FileLogObserver(errorLogFile).emit

            # Registering ILogObserver with the Application object
            # gets our observer picked up within AppLogger.start( )
            app.setComponent(ILogObserver, errorLogObserver)
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:14,代码来源:caldav.py


示例15: msg

 def msg(self, content=""):
     head = "=="*10+"START"+"=="*10
     tail = "=="*10+"=END="+"=="*10
     LogFile.write(self, "\n%d:%s\n" % (self.Counter, head))
     for line in content.split('\n'):
         if line != "":
             LogFile.write(self, "%d:%s\n" % (self.Counter, line))
     LogFile.write(self, "%d:%s\n" % (self.Counter, tail))
     self.Counter += 1
开发者ID:dinimicky,项目名称:drop_server,代码行数:9,代码来源:log.py


示例16: emmit

 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,代码行数:13,代码来源:logging.py


示例17: makeService

def makeService(config):

    # install simple, blocking DNS resolver.
    from twisted.internet import reactor
    from twisted.internet.base import BlockingResolver
    reactor.installResolver(BlockingResolver())

    try:
        # Create dbus mainloop
        import dbus.mainloop.glib
        dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
    except ImportError:
        warnings.warn('Failed to import the dbus module, some functionality might not work.')

    # Check if it is the right thing
    if not hasattr(config.module, 'Application'):
        raise usage.UsageError("Invalid application module: " + config.appName)

    # Instantiate the main application
    s = config.module.Application(config.appName, config.opts, config.appOpts)

    # Set quitflag
    s.quitFlag = launcher.QuitFlag(s.path("temp").child("quitflag"))

    # Set the name
    s.setName(config.appName)

    # make sure the relevant paths exist
    for kind in ["temp", "db"]:
        path = s.path(kind)
        if not path.exists():
            path.createDirectory()

    # Set up logging
    logFile = s.path("logfile")
    if not logFile.parent().exists():
        logFile.parent().createDirectory()
    filename = s.path("logfile").path

    if config.opts['no-logrotate']:
        observer = RotatableFileLogObserver(filename)
    else:
        logFile = LogFile.fromFullPath(filename, maxRotatedFiles=9)
        observer = log.FileLogObserver(logFile).emit
    log.addObserver(observer)

    return s
开发者ID:arjan,项目名称:sparked,代码行数:47,代码来源:tap.py


示例18: postOptions

 def postOptions(self):
     if self["journald"]:
         destination = JournaldDestination()
     else:
         if self["logfile"] is None:
             logfile = self._sys_module.stdout
         else:
             logfilepath = FilePath(self["logfile"])
             logfilepath_directory = logfilepath.parent()
             if not logfilepath_directory.exists():
                 logfilepath_directory.makedirs()
             # A twisted.python.logfile which has write and flush methods
             # but which also rotates the log file.
             logfile = LogFile.fromFullPath(
                 logfilepath.path, rotateLength=LOGFILE_LENGTH, maxRotatedFiles=LOGFILE_COUNT
             )
         destination = FileDestination(file=logfile)
     self.eliot_destination = destination
     original_postOptions(self)
开发者ID:Kaffa-MY,项目名称:flocker,代码行数:19,代码来源:script.py


示例19: receive_logs

    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,代码行数:20,代码来源:station_logs.py


示例20: initialize_twisted_logging

 def initialize_twisted_logging(self):
     twenty_megabytes = 20000000
     log_file = LogFile.fromFullPath(self.configuration['log_filename'],
                                     maxRotatedFiles=10,
                                     rotateLength=twenty_megabytes)
     log.startLogging(log_file)
开发者ID:andante-project,项目名称:yadtreceiver,代码行数:6,代码来源:__init__.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python modules.getModule函数代码示例发布时间:2022-05-27
下一篇:
Python logfile.DailyLogFile类代码示例发布时间: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