diff --git a/Doc/library/logging.rst b/Doc/library/logging.rst --- a/Doc/library/logging.rst +++ b/Doc/library/logging.rst @@ -2568,21 +2568,20 @@ Currently, the useful mapping keys in a .. versionchanged:: 2.5 *funcName* was added. .. class:: Formatter([fmt[, datefmt]]) Returns a new instance of the :class:`Formatter` class. The instance is - initialized with a format string for the message as a whole, as well as a format - string for the date/time portion of a message. If no *fmt* is specified, - ``'%(message)s'`` is used. If no *datefmt* is specified, the ISO8601 date format - is used. - + initialized with a format string for the message as a whole, as well as a + format string for the date/time portion of a message. If no *fmt* is + specified, ``'%(message)s'`` is used. If no *datefmt* is specified, the + ISO8601 date format is used. .. method:: format(record) The record's attribute dictionary is used as the operand to a string formatting operation. Returns the resulting string. Before formatting the dictionary, a couple of preparatory steps are carried out. The *message* attribute of the record is computed using *msg* % *args*. If the formatting string contains ``'(asctime)'``, :meth:`formatTime` is called @@ -2649,46 +2648,78 @@ etc.) This means that events which have will not be filtered by a logger's filter setting, unless the filter has also been applied to those descendant loggers. .. _log-record: LogRecord Objects ----------------- -:class:`LogRecord` instances are created every time something is logged. They -contain all the information pertinent to the event being logged. The main -information passed in is in msg and args, which are combined using msg % args to -create the message field of the record. The record also includes information -such as when the record was created, the source line where the logging call was -made, and any exception information to be logged. - - -.. class:: LogRecord(name, lvl, pathname, lineno, msg, args, exc_info [, func]) - - Returns an instance of :class:`LogRecord` initialized with interesting - information. The *name* is the logger name; *lvl* is the numeric level; - *pathname* is the absolute pathname of the source file in which the logging - call was made; *lineno* is the line number in that file where the logging - call is found; *msg* is the user-supplied message (a format string); *args* - is the tuple which, together with *msg*, makes up the user message; and - *exc_info* is the exception tuple obtained by calling :func:`sys.exc_info` - (or :const:`None`, if no exception information is available). The *func* is - the name of the function from which the logging call was made. If not - specified, it defaults to ``None``. +:class:`LogRecord` instances are created automatically by the :class:`Logger` +every time something is logged and can be created manually via +:func:`makeLogRecord`. + + +.. class:: + LogRecord(name, lvl, pathname, lineno, msg, args, exc_info [, func=None]) + + Contains all the information pertinent to the event being logged. + + The primary information is passed in :attr:`msg` and :attr:`args`, which + are combined using ``msg % args`` to create the :attr:`message` field of the + record. + + .. attribute:: name + + Name of the logger that emitted the record. + + .. attribute:: lvl + + Numeric logging level. + + .. attribute:: pathname + + Absolute pathname of the source file of origin (in which the logging call + was made). + + .. attribute:: lineno + + Line number in the source file of origin. + + .. attribute:: msg + + User-supplied :ref:`format string` used in + :meth:`getMessage`. + + .. attribute:: args + + Tuple of arguments to be used in formatting :attr:`msg`. + + .. attribute:: exc_info + + Exception tuple (a la `sys.exc_info`) or `None` if no exception + information is availble. + + .. attribute:: func + + Name of the function of origin. + + .. attribute:: message + + Bound to the result of :meth:`getMessage` when + :meth:`Formatter.format(record)` is invoked. + + .. method:: getMessage() + + Returns the message for this :class:`LogRecord` instance after merging any + user-supplied arguments with the message. .. versionchanged:: 2.5 *func* was added. - - .. method:: getMessage() - - Returns the message for this :class:`LogRecord` instance after merging any - user-supplied arguments with the message. - .. _logger-adapter: LoggerAdapter Objects --------------------- .. versionadded:: 2.6 :class:`LoggerAdapter` instances are used to conveniently pass contextual