當前位置: 首頁>>代碼示例>>Python>>正文


Python logbook.FileHandler方法代碼示例

本文整理匯總了Python中logbook.FileHandler方法的典型用法代碼示例。如果您正苦於以下問題:Python logbook.FileHandler方法的具體用法?Python logbook.FileHandler怎麽用?Python logbook.FileHandler使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在logbook的用法示例。


在下文中一共展示了logbook.FileHandler方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: setup_logbook

# 需要導入模塊: import logbook [as 別名]
# 或者: from logbook import FileHandler [as 別名]
def setup_logbook(logfile, logfile_kwargs=None):
  """Return a basic `logbook` setup which logs to `stderr` and to file."""

  if logfile_kwargs is None:
    logfile_kwargs = {}

  logfile_kwargs.setdefault('level', 'DEBUG')
  logfile_kwargs.setdefault('mode', 'w')
  logfile_kwargs.setdefault('bubble', True)
  logfile_kwargs.setdefault('format_string',
      ('--------------------------------------------------------------------------\n'
       '[{record.time} {record.level_name:<8s} {record.channel:>10s}]'
       ' {record.filename:s}:{record.lineno:d}\n{record.message:s}'))

  logbook_setup = logbook.NestedSetup([
    logbook.NullHandler(),
    logbook.more.ColorizedStderrHandler(level='INFO', bubble=False,
      format_string='[{record.level_name:<8s} {record.channel:s}] {record.message:s}'),
    logbook.FileHandler(logfile, **logfile_kwargs),
  ])

  return logbook_setup 
開發者ID:Netflix-Skunkworks,項目名稱:stethoscope,代碼行數:24,代碼來源:utils.py

示例2: init_logging_file

# 需要導入模塊: import logbook [as 別名]
# 或者: from logbook import FileHandler [as 別名]
def init_logging_file(filename, log_level='notset', rotate_log=True, rotate_max_size=10485760,
                      bubble=True):
    log_dir = os.path.dirname(filename)
    if not os.path.exists(log_dir):
        os.makedirs(log_dir)
    if rotate_log is True:
        handler = logbook.RotatingFileHandler(filename, level=figure_out_log_level(log_level),
                                              max_size=int(rotate_max_size), bubble=bubble)
    else:
        handler = logbook.FileHandler(filename, level=figure_out_log_level(log_level),
                                      bubble=bubble)
    handler.push_application()
    get_logger().debug("file based logging initialized in directory: " + log_dir) 
開發者ID:spotify,項目名稱:postgresql-metrics,代碼行數:15,代碼來源:common.py

示例3: setup_logger

# 需要導入模塊: import logbook [as 別名]
# 或者: from logbook import FileHandler [as 別名]
def setup_logger(test, path='test.log'):
    test.log_handler = FileHandler(path)
    test.log_handler.push_application() 
開發者ID:zhanghan1990,項目名稱:zipline-chinese,代碼行數:5,代碼來源:core.py

示例4: logging_context

# 需要導入模塊: import logbook [as 別名]
# 或者: from logbook import FileHandler [as 別名]
def logging_context(path=None, level=None):
    from logbook import StderrHandler, FileHandler
    from logbook.compat import redirected_logging
    with StderrHandler(level=level or 'INFO').applicationbound():
        if path:
            if not os.path.isdir(os.path.dirname(path)):
                os.makedirs(os.path.dirname(path))
            with FileHandler(path, bubble=True).applicationbound():
                with redirected_logging():
                    yield
        else:
            with redirected_logging():
                yield 
開發者ID:Answeror,項目名稱:srep,代碼行數:15,代碼來源:__init__.py


注:本文中的logbook.FileHandler方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。