| 13 | msg = '%(message)s' |
| 14 | |
| 15 | def format(self, record): |
| 16 | if record.levelno == logging.DEBUG: |
| 17 | mcl, mtxt = self._color_dbg, 'DBG' |
| 18 | elif record.levelno == logging.WARNING: |
| 19 | mcl, mtxt = self._color_warn, 'WRN' |
| 20 | elif record.levelno == logging.ERROR: |
| 21 | mcl, mtxt = self._color_err, 'ERR' |
| 22 | else: |
| 23 | mcl, mtxt = self._color_normal, '' |
| 24 | |
| 25 | if mtxt: |
| 26 | mtxt += ' ' |
| 27 | |
| 28 | if self.log_fout: |
| 29 | self.__set_fmt(self.date_full + mtxt + self.msg) |
| 30 | formatted = super(LogFormatter, self).format(record) |
| 31 | # self.log_fout.write(formatted) |
| 32 | # self.log_fout.write('\n') |
| 33 | # self.log_fout.flush() |
| 34 | return formatted |
| 35 | |
| 36 | self.__set_fmt(self._color_date(self.date) + mcl(mtxt + self.msg)) |
| 37 | formatted = super(LogFormatter, self).format(record) |
| 38 | |
| 39 | return formatted |
| 40 | |
| 41 | if sys.version_info.major < 3: |
| 42 | def __set_fmt(self, fmt): |