From d51a81de49a557861d19713d130e56a969aac271 Mon Sep 17 00:00:00 2001 From: "Casper V. Kristensen" Date: Sat, 6 Apr 2019 17:45:03 +0200 Subject: [PATCH] Logging on server. --- server/nightr/app.py | 8 ++++---- server/nightr/strategies/iss.py | 1 - 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/server/nightr/app.py b/server/nightr/app.py index cf488fe..63f9720 100644 --- a/server/nightr/app.py +++ b/server/nightr/app.py @@ -1,18 +1,17 @@ import inspect -import logging import statistics from dataclasses import asdict from datetime import timedelta from typing import List import requests_cache -from flask import Flask, jsonify +from flask import Flask, jsonify, logging from .strategies import miloStrats, iss, cars_in_traffic, tide_strat, upstairs_neighbour from .util import Context -logger = logging.getLogger(__name__) app = Flask(__name__) +logger = logging.create_logger(app) requests_cache.install_cache("requests_cache", expire_after=timedelta(minutes=10)) @@ -39,9 +38,10 @@ def probabilities(): try: prediction = strategy(context) except Exception as e: - logger.warning("Strategy %s failed: %s", name, e) + logger.warning("Strategy '%s' failed: %s:", name) logger.exception(e) continue + predictions.append({ "name": name, "description": inspect.getdoc(strategy), diff --git a/server/nightr/strategies/iss.py b/server/nightr/strategies/iss.py index 17ed941..e4ca5de 100644 --- a/server/nightr/strategies/iss.py +++ b/server/nightr/strategies/iss.py @@ -9,7 +9,6 @@ from timezonefinder import TimezoneFinder from ..util import Context, Prediction -logger = logging.getLogger(__name__) tf = TimezoneFinder(in_memory=True)