From 8f05ebbc3ca472cddfe11a595dc734de2a6e5700 Mon Sep 17 00:00:00 2001 From: Borja Esteban Date: Wed, 3 Aug 2022 15:15:41 +0200 Subject: [PATCH 1/5] Simplify logging in FastAPI example --- examples/example_fastapi.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/examples/example_fastapi.py b/examples/example_fastapi.py index 114a1e3..ab8967d 100644 --- a/examples/example_fastapi.py +++ b/examples/example_fastapi.py @@ -1,4 +1,5 @@ # Flaat example with FastAPI +import logging from fastapi import Depends, FastAPI, Request, Response from fastapi.security import HTTPBasicCredentials, HTTPBearer from flaat import AuthWorkflow @@ -8,11 +9,14 @@ from flaat.requirements import get_claim_requirement from flaat.requirements import get_vo_requirement -from examples import logsetup # ------------------------------------------------------------------ # Basic configuration example --------------------------------------- -logger = logsetup.setup_logging() +logging.basicConfig(level="WARNING") +logging.getLogger("flaat").setLevel("DEBUG") +logging.getLogger("urllib3").setLevel("DEBUG") + +# logging.basicConfig(level="DEBUG") ADMIN_EMAILS = ["admin@foo.org", "dev@foo.org"] From e9067f8e31b034be431a611c2c196489c7422384 Mon Sep 17 00:00:00 2001 From: Borja Esteban Date: Wed, 3 Aug 2022 15:20:08 +0200 Subject: [PATCH 2/5] Simplify logging in Flask example --- examples/example_flask.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/example_flask.py b/examples/example_flask.py index d076209..e81a613 100644 --- a/examples/example_flask.py +++ b/examples/example_flask.py @@ -1,4 +1,5 @@ # Flaat example with Flask +import logging from flaat import AuthWorkflow from flaat.config import AccessLevel from flaat.flask import Flaat @@ -9,11 +10,12 @@ from flask import Blueprint, Flask, abort, current_app from werkzeug import Response -from examples import logsetup # ------------------------------------------------------------------ # Basic configuration example --------------------------------------- -logger = logsetup.setup_logging() +logging.basicConfig(level="WARNING") +logging.getLogger("flaat").setLevel("DEBUG") +logging.getLogger("werkzeug").setLevel("DEBUG") # Standard flask blueprint snippet, source: # https://flask.palletsprojects.com/en/2.1.x/blueprints From e2b30cbfc4f41fe10bd1076b97792ddd7c7bd4cb Mon Sep 17 00:00:00 2001 From: Borja Esteban Date: Wed, 3 Aug 2022 15:21:53 +0200 Subject: [PATCH 3/5] Simplify logging in aio example --- examples/example_aio.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/examples/example_aio.py b/examples/example_aio.py index 94aef56..e30e178 100644 --- a/examples/example_aio.py +++ b/examples/example_aio.py @@ -1,14 +1,17 @@ -from aiohttp import web +import logging -from examples.logsetup import setup_logging +from aiohttp import web from flaat import AuthWorkflow from flaat.aio import Flaat from flaat.exceptions import FlaatException -from flaat.requirements import CheckResult, get_claim_requirement, get_vo_requirement +from flaat.requirements import CheckResult +from flaat.requirements import get_claim_requirement +from flaat.requirements import get_vo_requirement from flaat.user_infos import UserInfos # do some log setup so we can see something -setup_logging() +logging.basicConfig(level="WARNING") +logging.getLogger("flaat").setLevel("DEBUG") ########## From 447611f1413c11de5f3cf2152d732d05c6dbfb93 Mon Sep 17 00:00:00 2001 From: Borja Esteban Date: Wed, 3 Aug 2022 15:22:56 +0200 Subject: [PATCH 4/5] del unused logsetup --- examples/logsetup.py | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100644 examples/logsetup.py diff --git a/examples/logsetup.py b/examples/logsetup.py deleted file mode 100644 index b5ca911..0000000 --- a/examples/logsetup.py +++ /dev/null @@ -1,19 +0,0 @@ -import logging -import sys - - -def setup_logging(): - """setup logging""" - formatter = logging.Formatter("%(levelname)s - %(message)s") - - handler = logging.StreamHandler(sys.stderr) - handler.setFormatter(formatter) - - rootLogger = logging.getLogger() - rootLogger.addHandler(handler) - rootLogger.setLevel(logging.DEBUG) - - # turn off other logging: - for other in ["werkzeug", "urllib3"]: - other_log = logging.getLogger(other) - other_log.setLevel(logging.CRITICAL) From 512ba58a971311177f056118e75c62cda2336d8c Mon Sep 17 00:00:00 2001 From: BorjaEst Date: Thu, 4 Aug 2022 11:43:02 +0200 Subject: [PATCH 5/5] del comment log from fastAPI example --- examples/example_fastapi.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/examples/example_fastapi.py b/examples/example_fastapi.py index ab8967d..643a0ac 100644 --- a/examples/example_fastapi.py +++ b/examples/example_fastapi.py @@ -15,8 +15,6 @@ logging.basicConfig(level="WARNING") logging.getLogger("flaat").setLevel("DEBUG") logging.getLogger("urllib3").setLevel("DEBUG") - -# logging.basicConfig(level="DEBUG") ADMIN_EMAILS = ["admin@foo.org", "dev@foo.org"]