我们从Python开源项目中,提取了以下6个代码示例,用于说明如何使用logbook.TimedRotatingFileHandler()。
def global_init(log_level_text, filename): level = LogService.__get_logbook_logging_level(log_level_text) if not filename: logbook.StreamHandler(sys.stdout, level=level).push_application() else: logbook.TimedRotatingFileHandler( filename, level=level, date_format="%Y-%m-%d").push_application() msg = 'Logging initialized, level: {}, mode: {}'.format( log_level_text, "stdout mode" if not filename else 'file mode: ' + filename ) LogService.get_startup_log().notice(msg)
def get_logger(name='monkey??????????', file_log=file_stream, level=''): """ get logger Factory function """ logbook.set_datetime_format('local') ColorizedStderrHandler(bubble=False, level=level).push_thread() logbook.TimedRotatingFileHandler( os.path.join(LOG_DIR, '%s.log' % name), date_format='%Y-%m-%d-%H', bubble=True, encoding='utf-8').push_thread() return logbook.Logger(name)
def get_logger(name='jiekou', file_log=file_stream, level=''): """ get logger Factory function """ logbook.set_datetime_format('local') ColorizedStderrHandler(bubble=False, level=level).push_thread() logbook.TimedRotatingFileHandler( os.path.join(LOG_DIR, '%s.log' % name), date_format='%Y-%m-%d-%H', bubble=True, encoding='utf-8').push_thread() return logbook.Logger(name)