Browse Source

Add calefaction.enable_logging() function.

master
Ben Kurtovic 8 years ago
parent
commit
1d511fe4d4
3 changed files with 16 additions and 3 deletions
  1. +2
    -0
      app.py
  2. +12
    -0
      calefaction/__init__.py
  3. +2
    -3
      calefaction/auth.py

+ 2
- 0
app.py View File

@@ -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():


+ 12
- 0
calefaction/__init__.py View File

@@ -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)

+ 2
- 3
calefaction/auth.py View File

@@ -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,


Loading…
Cancel
Save