From c63847a576b827f3843f4b8a0a7a83c27384498b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Gru=CC=88ndger?= Date: Fri, 20 Nov 2020 21:26:10 +0100 Subject: [PATCH] Improve logging --- app/commands/gateway.py | 1 - app/gateway/beacon_conversion.py | 4 +++- app/utils.py | 4 +++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/commands/gateway.py b/app/commands/gateway.py index b771c34..8d8319a 100644 --- a/app/commands/gateway.py +++ b/app/commands/gateway.py @@ -8,7 +8,6 @@ import click from tqdm import tqdm from ogn.client import AprsClient -from ogn.parser import parse from app import redis_client from app.gateway.beacon_conversion import aprs_string_to_message diff --git a/app/gateway/beacon_conversion.py b/app/gateway/beacon_conversion.py index 4e7be5f..58e6408 100644 --- a/app/gateway/beacon_conversion.py +++ b/app/gateway/beacon_conversion.py @@ -1,3 +1,5 @@ +from flask import current_app + from mgrs import MGRS from ogn.parser import parse @@ -14,7 +16,7 @@ def aprs_string_to_message(aprs_string): try: message = parse(aprs_string, calculate_relations=True) except Exception as e: - print(e) + current_app.logger.debug(e) return None if message['aprs_type'] not in ('position', 'status'): diff --git a/app/utils.py b/app/utils.py index 54a3fe9..b6c59fe 100644 --- a/app/utils.py +++ b/app/utils.py @@ -3,6 +3,8 @@ import gzip from io import StringIO from datetime import datetime, timedelta +from flask import current_app + from aerofiles.seeyou import Reader from ogn.parser.utils import FEETS_TO_METER import requests @@ -118,7 +120,7 @@ def get_airports(cupfile): airports.append(airport) except AttributeError as e: - print("Failed to parse line: {} {}".format(line, e)) + current_app.logger.error("Failed to parse line: {} {}".format(line, e)) return airports