MCPcopy Index your code
hub / github.com/RustPython/RustPython / Formatter

Class Formatter

Lib/logging/__init__.py:554–729  ·  view source on GitHub ↗

Formatter instances are used to convert a LogRecord to text. Formatters need to know how a LogRecord is constructed. They are responsible for converting a LogRecord to (usually) a string which can be interpreted by either a human or an external system. The base Formatter allows

Source from the content-addressed store, hash-verified

552}
553
554class Formatter(object):
555 """
556 Formatter instances are used to convert a LogRecord to text.
557
558 Formatters need to know how a LogRecord is constructed. They are
559 responsible for converting a LogRecord to (usually) a string which can
560 be interpreted by either a human or an external system. The base Formatter
561 allows a formatting string to be specified. If none is supplied, the
562 style-dependent default value, "%(message)s", "{message}", or
563 "${message}", is used.
564
565 The Formatter can be initialized with a format string which makes use of
566 knowledge of the LogRecord attributes - e.g. the default value mentioned
567 above makes use of the fact that the user's message and arguments are pre-
568 formatted into a LogRecord's message attribute. Currently, the useful
569 attributes in a LogRecord are described by:
570
571 %(name)s Name of the logger (logging channel)
572 %(levelno)s Numeric logging level for the message (DEBUG, INFO,
573 WARNING, ERROR, CRITICAL)
574 %(levelname)s Text logging level for the message ("DEBUG", "INFO",
575 "WARNING", "ERROR", "CRITICAL")
576 %(pathname)s Full pathname of the source file where the logging
577 call was issued (if available)
578 %(filename)s Filename portion of pathname
579 %(module)s Module (name portion of filename)
580 %(lineno)d Source line number where the logging call was issued
581 (if available)
582 %(funcName)s Function name
583 %(created)f Time when the LogRecord was created (time.time_ns() / 1e9
584 return value)
585 %(asctime)s Textual time when the LogRecord was created
586 %(msecs)d Millisecond portion of the creation time
587 %(relativeCreated)d Time in milliseconds when the LogRecord was created,
588 relative to the time the logging module was loaded
589 (typically at application startup time)
590 %(thread)d Thread ID (if available)
591 %(threadName)s Thread name (if available)
592 %(taskName)s Task name (if available)
593 %(process)d Process ID (if available)
594 %(processName)s Process name (if available)
595 %(message)s The result of record.getMessage(), computed just as
596 the record is emitted
597 """
598
599 converter = time.localtime
600
601 def __init__(self, fmt=None, datefmt=None, style='%', validate=True, *,
602 defaults=None):
603 """
604 Initialize the formatter with specified format strings.
605
606 Initialize the formatter either with the specified format string, or a
607 default as described above. Allow for specialized date formatting with
608 the optional datefmt argument. If datefmt is omitted, you get an
609 ISO8601-like (or RFC 3339-like) format.
610
611 Use a style parameter of '%', '{' or '$' to specify that you want to

Callers 2

__init__.pyFile · 0.70
basicConfigFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected