Отключить регистрацию запросов на консоли в колбе - PullRequest
0 голосов
/ 27 декабря 2018

Я попробовал все здесь: Отключить консольные сообщения на сервере Flask , но единственное, что мне удалось сделать, это отключить * запуск сервера.

Я нашел то, что похоже на егофункции в модуле werkzeug в Serving.py:

def log_request(self, code='-', size='-'):
    msg = self.requestline
    code = str(code)

    if termcolor:
        color = termcolor.colored

        if code[0] == '1':    # 1xx - Informational
            msg = color(msg, attrs=['bold'])
        elif code[0] == '2':    # 2xx - Success
            msg = color(msg, color='white')
        elif code == '304':   # 304 - Resource Not Modified
            msg = color(msg, color='cyan')
        elif code[0] == '3':  # 3xx - Redirection
            msg = color(msg, color='green')
        elif code == '404':   # 404 - Resource Not Found
            msg = color(msg, color='yellow')
        elif code[0] == '4':  # 4xx - Client Error
            msg = color(msg, color='red', attrs=['bold'])
        else:                 # 5xx, or any other response
            msg = color(msg, color='magenta', attrs=['bold'])

    self.log('info', '"%s" %s %s', msg, code, size)


def log(self, type, message, *args):
    _log(type, '%s - - [%s] %s\n' % (self.address_string(),
                                     self.log_date_time_string(),
                                     message % args))

Но даже при добавлении pass во все эти функции вместо кода он выводит их на консоль.Я действительно невежественен.У кого-нибудь есть рабочее решение для этого?

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...