'Logs various different kinds of requests to the console.'

def log_action(self, protocol, action, details):

    msg = ('[%s]    ' % datetime.datetime.now().strftime('%Y/%m/%d    %H:%M:%S'))
    if ((protocol == 'http') and (action == 'complete')):
        msg += ('HTTP    %(method)s    %(path)s    %(status)s    [%(time_taken).2f,    %(client)s]\n' % details)
        if (200 <= details['status'] < 300):
            msg = self.style.HTTP_SUCCESS(msg)
        elif (100 <= details['status'] < 200):
            msg = self.style.HTTP_INFO(msg)
        elif (details['status'] == 304):
            msg = self.style.HTTP_NOT_MODIFIED(msg)
        elif (300 <= details['status'] < 400):
            msg = self.style.HTTP_REDIRECT(msg)
        elif (details['status'] == 404):
            msg = self.style.HTTP_NOT_FOUND(msg)
        elif (400 <= details['status'] < 500):
            msg = self.style.HTTP_BAD_REQUEST(msg)
        else:
            msg = self.style.HTTP_SERVER_ERROR(msg)
    elif ((protocol == 'websocket') and (action == 'connected')):
        msg += ('WebSocket    CONNECT    %(path)s    [%(client)s]\n' % details)
    elif ((protocol == 'websocket') and (action == 'disconnected')):
        msg += ('WebSocket    DISCONNECT    %(path)s    [%(client)s]\n' % details)
    elif ((protocol == 'websocket') and (action == 'connecting')):
        msg += ('WebSocket    HANDSHAKING    %(path)s    [%(client)s]\n' % details)
    elif ((protocol == 'websocket') and (action == 'rejected')):
        msg += ('WebSocket    REJECT    %(path)s    [%(client)s]\n' % details)
    sys.stderr.write(msg)
