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


Python DailyLogFile.write方法代码示例

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


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

示例1: PrintLogThread

# 需要导入模块: from twisted.python.logfile import DailyLogFile [as 别名]
# 或者: from twisted.python.logfile.DailyLogFile import write [as 别名]
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,代码行数:37,代码来源:output.py

示例2: write

# 需要导入模块: from twisted.python.logfile import DailyLogFile [as 别名]
# 或者: from twisted.python.logfile.DailyLogFile import write [as 别名]
 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,代码行数:12,代码来源:log.py

示例3: initLog

# 需要导入模块: from twisted.python.logfile import DailyLogFile [as 别名]
# 或者: from twisted.python.logfile.DailyLogFile import write [as 别名]
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,代码行数:20,代码来源:tylog.py

示例4: ChatLogger

# 需要导入模块: from twisted.python.logfile import DailyLogFile [as 别名]
# 或者: from twisted.python.logfile.DailyLogFile import write [as 别名]
class ChatLogger(object):
    def __init__(self, logfile, path):
        self.log = DailyLogFile(logfile, path)
        date = datetime.now().strftime('%a %b %d %H:%M %Y')
        self.log.write('--- Log opened: %s\n' % (date, ))

    def write_line(self, line):
        self.log.write(datetime.now().strftime('%H:%M '))
        if isinstance(line, unicode):
            line = line.encode('utf-8')
        self.log.write(line)
        self.log.write('\n')
        self.log.flush()

    def action(self, nick, message):
        self.write_line(' * %s %s' % (nick, message))

    def message(self, nick, message):
        self.write_line('<%s> %s' % (nick, message))
开发者ID:Trundle,项目名称:kitbot,代码行数:21,代码来源:bot.py

示例5: write

# 需要导入模块: from twisted.python.logfile import DailyLogFile [as 别名]
# 或者: from twisted.python.logfile.DailyLogFile import write [as 别名]
 def write(self, data):
   if not self.enableRotation:
     if not os.path.exists(self.path):
       self.reopen()
   DailyLogFile.write(self, data)
开发者ID:jacklesplat,项目名称:ql_emc_graphite,代码行数:7,代码来源:log.py

示例6: SuccessMessage

# 需要导入模块: from twisted.python.logfile import DailyLogFile [as 别名]
# 或者: from twisted.python.logfile.DailyLogFile import write [as 别名]
    intervaltime=string.atof(intervaltime)
    bittime=string.atof(bittime)
    takttime=string.atof(takttime)
    if(self!=''):
        SuccessMessage(self,'01','',True)
    return 

ReadConig('')
number_of_connections = 0
echo_debug = 2 #1不显示  2基本信息  3 控制信息


application = Application("myapp")
logFile = DailyLogFile("my.log", "log")
application.setComponent(ILogObserver, FileLogObserver(logFile).emit)
logFile.write('begin...\r\n')


log.startLogging(sys.stdout)
log.msg('begin...')


############### 公共函数 ###############
def LogWrite(self,str,line='',send=''):
        ''' 记录日志  '''
        
        logstr = FormatlogMsg(self,str,line,send)
        logFile.write( logstr )
        if (DEBUGERR==True):
                if(str!=''):
                    log.msg( str )
开发者ID:verylove,项目名称:YTJbc,代码行数:33,代码来源:Server.py


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