def formatMessage(self, record): s = Formatter.formatMessage(self, record) name = record.name lvlno = record.levelno logger = getLogger(name) color = { DEBUG: 'none', CHAT: 'cyan', INFO: 'cyan', NOTE: 'cyan', WARNING: 'yellow', ERROR: 'red', CRITICAL: 'red', }[lvlno] if lvlno == DEBUG or getattr(record, 'no_marker', False): marker = '' elif logger.isEnabledFor(DEBUG): marker = { DEBUG: '', CHAT: 'chat', INFO: 'info', NOTE: 'note', WARNING: 'warn', ERROR: 'error', CRITICAL: 'crit', }[lvlno] marker = "%s:%s" % (marker, self.shorter_name(name)) elif logger.isEnabledFor(CHAT): marker = { DEBUG: '', CHAT: '[i:%s]', INFO: '[i:%s]', NOTE: '[i:%s]', WARNING: '[w:%s]', ERROR: '[!:%s]', CRITICAL: '[!:%s]', }[lvlno] marker = marker % self.shorter_name(name) else: marker = { DEBUG: '', CHAT: '[i]', INFO: '[i]', NOTE: '[i]', WARNING: '[w]', ERROR: '[!]', CRITICAL: '[!]', }[lvlno] use_colors = getLogger('byexample').use_colors if marker and not getattr(record, 'disable_prefix', False): marker = colored(marker, color, use_colors=use_colors) s = "%s %s" % (marker, s) ex = getattr(record, 'example', None) if ex is not None: if logger.isEnabledFor(DEBUG): ex.pretty_print() else: s += '\n' + indent(highlight_syntax(ex, use_colors)) return s