From 14f2522c3e9f84b97246ed3ff8abc60683f65ff5 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Thu, 18 Mar 2021 15:16:43 +0100 Subject: [PATCH] events: improve logging for geoip Signed-off-by: Jens Langhammer --- authentik/events/geo.py | 8 ++++++-- authentik/events/models.py | 4 ++-- web/src/elements/router/RouterOutlet.ts | 1 - 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/authentik/events/geo.py b/authentik/events/geo.py index f7e2f90cb..ac1eecabe 100644 --- a/authentik/events/geo.py +++ b/authentik/events/geo.py @@ -1,11 +1,13 @@ """events GeoIP Reader""" - from typing import Optional from geoip2.database import Reader +from structlog.stdlib import get_logger from authentik.lib.config import CONFIG +LOGGER = get_logger() + def get_geoip_reader() -> Optional[Reader]: """Get GeoIP Reader, if configured, otherwise none""" @@ -13,7 +15,9 @@ def get_geoip_reader() -> Optional[Reader]: if path == "" or not path: return None try: - return Reader(path) + reader = Reader(path) + LOGGER.info("Enabled GeoIP support") + return reader except OSError: return None diff --git a/authentik/events/models.py b/authentik/events/models.py index 14911fb38..9ef5fc38c 100644 --- a/authentik/events/models.py +++ b/authentik/events/models.py @@ -156,8 +156,8 @@ class Event(models.Model): } if response.city.name: self.context["geo"]["city"] = response.city.name - except GeoIP2Error: - pass + except GeoIP2Error as exc: + LOGGER.warning("Failed to add geoIP Data to event", exc=exc) def save(self, *args, **kwargs): if self._state.adding: diff --git a/web/src/elements/router/RouterOutlet.ts b/web/src/elements/router/RouterOutlet.ts index 38f3d2fec..d702b389e 100644 --- a/web/src/elements/router/RouterOutlet.ts +++ b/web/src/elements/router/RouterOutlet.ts @@ -46,7 +46,6 @@ export class RouterOutlet extends LitElement { updated(): void { if (!this.shadowRoot) return; Array.from(this.shadowRoot?.children).forEach((el) => { - console.log("pageTitle" in el); if ("pageTitle" in el) { const title = (el as Page).pageTitle(); document.title = `${title} - ${TITLE_SUFFIX}`;