From 1d511fe4d43cef85fe2a003f83ceb69e3434f83f Mon Sep 17 00:00:00 2001 From: Ben Kurtovic Date: Tue, 20 Dec 2016 04:56:20 -0500 Subject: [PATCH] Add calefaction.enable_logging() function. --- app.py | 2 ++ calefaction/__init__.py | 12 ++++++++++++ calefaction/auth.py | 5 ++--- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/app.py b/app.py index e0028bb..3f503d1 100755 --- a/app.py +++ b/app.py @@ -23,6 +23,7 @@ config = Config(basepath / "config") Database.path = str(basepath / "data" / "db.sqlite3") eve = EVE(config) auth = AuthManager(config, eve) + catch_exceptions = make_error_catcher(app, "error.mako") route_restricted = make_route_restricter( auth, lambda: redirect(url_for("index"), 303)) @@ -30,6 +31,7 @@ route_restricted = make_route_restricter( MakoTemplates(app) set_up_asset_versioning(app) config.install(app) +calefaction.enable_logging() @app.before_request def prepare_request(): diff --git a/calefaction/__init__.py b/calefaction/__init__.py index 3049625..99e9ee7 100644 --- a/calefaction/__init__.py +++ b/calefaction/__init__.py @@ -5,3 +5,15 @@ __release__ = "0.1" baseLogger = logging.getLogger("calefaction") del logging + +def enable_logging(): + import logging + + fmt = "%(asctime)s [%(levelname)s] %(name)s: %(message)s" + datefmt = "%Y-%m-%d %H:%M:%S" + + formatter = logging.Formatter(fmt=fmt, datefmt=datefmt) + handler = logging.StreamHandler() + handler.setFormatter(formatter) + baseLogger.addHandler(handler) + baseLogger.setLevel(logging.DEBUG) diff --git a/calefaction/auth.py b/calefaction/auth.py index 018fb3b..63e4c85 100644 --- a/calefaction/auth.py +++ b/calefaction/auth.py @@ -204,13 +204,12 @@ class AuthManager: EVEAPIError or AccessDeniedError may be raised. """ - if "id" in session: - self._debug("Checking auth for session id=%d", session["id"]) - cid = self.get_character_id() if not cid: return False + self._debug("Checking auth for session id=%d", session["id"]) + token = self._get_token(cid) if not token: self._debug("No valid token for char id=%d session id=%d", cid,