'Apply various heuristics to return a colorized version of a string.
If these fail, simply return the string in plaintext.'

def colorize_log_entry(self, string):

    final_string = string
    try:
        inside_squares = re.findall(u'\\[([^]]*)\\]', string)
        for token in inside_squares:
            if (token in [u'CRITICAL', u'ERROR', u'WARNING', u'DEBUG', u'INFO', u'NOTSET']):
                final_string = final_string.replace(((u'[' + token) + u']'), ((click.style(u'[', fg=u'cyan') + click.style(token, fg=u'cyan', bold=True)) + click.style(u']', fg=u'cyan')))
            else:
                final_string = final_string.replace(((u'[' + token) + u']'), ((click.style(u'[', fg=u'cyan') + click.style(token, bold=True)) + click.style(u']', fg=u'cyan')))
        quotes = re.findall(u'"[^"]*"', string)
        for token in quotes:
            final_string = final_string.replace(token, click.style(token, fg=u'yellow'))
        for token in final_string.replace(u' DCTB ', u'    ').split(u'    '):
            try:
                if ((token.count(u'-') is 4) and token.replace(u'-', u'').isalnum()):
                    final_string = final_string.replace(token, click.style(token, fg=u'magenta'))
            except Exception:
                pass
            try:
                if ((token.count(u'.') is 3) and token.replace(u'.', u'').isnumeric()):
                    final_string = final_string.replace(token, click.style(token, fg=u'red'))
            except Exception:
                pass
            try:
                if (token in [u'200']):
                    final_string = final_string.replace(token, click.style(token, fg=u'green'))
                if (token in [u'400', u'401', u'403', u'404', u'405', u'500']):
                    final_string = final_string.replace(token, click.style(token, fg=u'red'))
            except Exception:
                pass
        try:
            if (u'Zappa    Event:' in final_string):
                final_string = final_string.replace(u'Zappa    Event:', click.style(u'Zappa    Event:', bold=True, fg=u'green'))
        except Exception:
            pass
        for token in final_string.split(u' DCTB '):
            try:
                is_date = parser.parse(token)
                final_string = final_string.replace(token, click.style(token, fg=u'green'))
            except Exception:
                pass
        final_string = final_string.replace(u' DCTB ', u'    ').replace(u'            ', u'    ')
        if (final_string[0] != u'    '):
            final_string = (u'    ' + final_string)
        return final_string
    except Exception as e:
        return string
