Return the creation time of the specified LogRecord as formatted text. This method should be called from format() by a formatter which wants to make use of a formatted time. This method can be overridden in formatters to provide for any specific requirement, but the
(self, record, datefmt=None)
| 629 | default_msec_format = '%s,%03d' |
| 630 | |
| 631 | def formatTime(self, record, datefmt=None): |
| 632 | """ |
| 633 | Return the creation time of the specified LogRecord as formatted text. |
| 634 | |
| 635 | This method should be called from format() by a formatter which |
| 636 | wants to make use of a formatted time. This method can be overridden |
| 637 | in formatters to provide for any specific requirement, but the |
| 638 | basic behaviour is as follows: if datefmt (a string) is specified, |
| 639 | it is used with time.strftime() to format the creation time of the |
| 640 | record. Otherwise, an ISO8601-like (or RFC 3339-like) format is used. |
| 641 | The resulting string is returned. This function uses a user-configurable |
| 642 | function to convert the creation time to a tuple. By default, |
| 643 | time.localtime() is used; to change this for a particular formatter |
| 644 | instance, set the 'converter' attribute to a function with the same |
| 645 | signature as time.localtime() or time.gmtime(). To change it for all |
| 646 | formatters, for example if you want all logging times to be shown in GMT, |
| 647 | set the 'converter' attribute in the Formatter class. |
| 648 | """ |
| 649 | ct = self.converter(record.created) |
| 650 | if datefmt: |
| 651 | s = time.strftime(datefmt, ct) |
| 652 | else: |
| 653 | s = time.strftime(self.default_time_format, ct) |
| 654 | if self.default_msec_format: |
| 655 | s = self.default_msec_format % (s, record.msecs) |
| 656 | return s |
| 657 | |
| 658 | def formatException(self, ei): |
| 659 | """ |