Skip to content

Commit

Permalink
Disable werkzeug logs correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
jxdv committed Dec 31, 2023
1 parent e8b30a1 commit b5d5211
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions graphenex/core/web/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import socket
import secrets
import logging
import webbrowser

from flask import Flask
Expand All @@ -9,6 +10,7 @@
from graphenex.core.utils.logcl import GraphenexLogger

logger = GraphenexLogger(__name__)
logging.getLogger('werkzeug').disabled = True
app = Flask(__name__)
app.config['SECRET_KEY'] = '77a98d7971ec94c8aae6dd2d'
app.config['ACCESS_TOKEN'] = secrets.token_urlsafe(6)
Expand All @@ -19,17 +21,9 @@
from graphenex.core.web.providers import * # noqa


def disable_flask_logs():
"""Disable Flask logs"""

import logging
logging.getLogger('werkzeug').setLevel(logging.ERROR)


def run_server(args=None, exit_shell=True):
"""Run the web server"""

disable_flask_logs()
try:
if args:
server_params = args['host_port'].split(':') \
Expand All @@ -56,4 +50,4 @@ def run_server(args=None, exit_shell=True):
if e.errno == 98:
logger.error(f"{server_params[0]}:{server_params[1]} is already in use!")
except Exception as e:
logger.error('An error occurred: ' + str(e))
logger.error(f'An error occurred: {e}')

0 comments on commit b5d5211

Please sign in to comment.