MCPcopy Index your code
hub / github.com/python/cpython / format

Method format

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

Format the specified record as text. The record's attribute dictionary is used as the operand to a string formatting operation which yields the returned string. Before formatting the dictionary, a couple of preparatory steps are carried out. The message attr

(self, record)

Source from the content-addressed store, hash-verified

697 return stack_info
698
699 def format(self, record):
700 """
701 Format the specified record as text.
702
703 The record's attribute dictionary is used as the operand to a
704 string formatting operation which yields the returned string.
705 Before formatting the dictionary, a couple of preparatory steps
706 are carried out. The message attribute of the record is computed
707 using LogRecord.getMessage(). If the formatting string uses the
708 time (as determined by a call to usesTime(), formatTime() is
709 called to format the event time. If there is exception information,
710 it is formatted using formatException() and appended to the message.
711 """
712 record.message = record.getMessage()
713 if self.usesTime():
714 record.asctime = self.formatTime(record, self.datefmt)
715 s = self.formatMessage(record)
716 if record.exc_info:
717 # Cache the traceback text to avoid converting it multiple times
718 # (it's constant anyway)
719 if not record.exc_text:
720 record.exc_text = self.formatException(record.exc_info)
721 if record.exc_text:
722 if s[-1:] != "\n":
723 s = s + "\n"
724 s = s + record.exc_text
725 if record.stack_info:
726 if s[-1:] != "\n":
727 s = s + "\n"
728 s = s + self.formatStack(record.stack_info)
729 return s
730
731#
732# The default formatter to use when no other is specified

Callers

nothing calls this directly

Calls 6

usesTimeMethod · 0.95
formatTimeMethod · 0.95
formatMessageMethod · 0.95
formatExceptionMethod · 0.95
formatStackMethod · 0.95
getMessageMethod · 0.45

Tested by

no test coverage detected