trying to fix logging

This commit is contained in:
2020-05-15 23:19:01 -05:00
parent 3bd9d24a97
commit 26340f118f
9 changed files with 66 additions and 39 deletions

@ -1,3 +1,5 @@
import logging
from logging.config import dictConfig as logging_dict_config
import os
@ -13,9 +15,12 @@ from capsulflask.btcpay import client as btcpay
load_dotenv(find_dotenv())
app = Flask(__name__)
app.config.from_mapping(
BASE_URL=os.environ.get("BASE_URL", default="http://localhost:5000"),
SECRET_KEY=os.environ.get("SECRET_KEY", default="dev"),
LOG_LEVEL=os.environ.get("LOG_LEVEL", default="INFO"),
DATABASE_URL=os.environ.get("DATABASE_URL", default="sql://postgres:dev@localhost:5432/postgres"),
DATABASE_SCHEMA=os.environ.get("DATABASE_SCHEMA", default="public"),
@ -37,6 +42,28 @@ app.config.from_mapping(
BTCPAY_URL=os.environ.get("BTCPAY_URL", default="https://btcpay.cyberia.club")
)
logging_dict_config({
'version': 1,
'formatters': {'default': {
'format': '[%(asctime)s] %(levelname)s in %(module)s: %(message)s',
}},
'handlers': {'wsgi': {
'class': 'logging.StreamHandler',
'stream': 'ext://flask.logging.wsgi_errors_stream',
'formatter': 'default'
}},
'root': {
'level': app.config['LOG_LEVEL'],
'handlers': ['wsgi']
}
})
# app.logger.critical("critical")
# app.logger.error("error")
# app.logger.warning("warning")
# app.logger.info("info")
# app.logger.debug("debug")
stripe.api_key = app.config['STRIPE_SECRET_KEY']
stripe.api_version = app.config['STRIPE_API_VERSION']
@ -59,5 +86,3 @@ app.register_blueprint(cli.bp)
app.add_url_rule("/", endpoint="index")
if __name__ == "__main__":
app.run(host='127.0.0.1')