'Colorize a message for a logging event.
This implementation uses the ``level_map`` class attribute to
map the LogRecord\'s level to a colour/intensity setting, which is
then applied to the whole message.
:param message: The message to colorize.
:param record: The ``LogRecord`` for the message.'

def colorize(self, message, record):

    if (record.levelno in self.level_map):
        (bg, fg, bold) = self.level_map[record.levelno]
        params = []
        if (bg in self.color_map):
            params.append(str((self.color_map[bg] + 40)))
        if (fg in self.color_map):
            params.append(str((self.color_map[fg] + 30)))
        if bold:
            params.append('1')
        if params:
            message = ''.join((self.csi, ';'.join(params), 'm', message, self.reset))
    return message
