On this page
  1. logging.BufferingFormatter
  2. Import
  3. Signature & Overview
  4. Methods & Attributes
  5. Usage
  6. Gotchas
  7. REPL Inspect

logging.BufferingFormatter

Prev: logging.basicConfig | Up: logging | Next: logging.captureWarnings
Rel: logging.addLevelName, logging.basicConfig, logging.captureWarnings, logging.critical
Ref: docs.python.org — logging.BufferingFormatter
Tags: #public #python3 #stdlib #logging


Import

import logging
from logging import BufferingFormatter

Signature & Overview

logging.BufferingFormatter(linefmt=None)

A formatter suitable for formatting a number of records.

Methods & Attributes

Usage

import logging

class WrapFormatter(logging.BufferingFormatter):
    def formatHeader(self, records): return "=== START ===\n"
    def formatFooter(self, records): return "=== END ===\n"

fmt = WrapFormatter(logging.Formatter("%(levelname)s:%(message)s\n"))
rec = logging.LogRecord("app", logging.INFO, "", 1, "ok", (), None)
assert "=== START ===" in fmt.format([rec])

Gotchas

REPL Inspect

from logging import BufferingFormatter
help(BufferingFormatter)

Linked from

Related notes