events: improve logging for geoip

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-03-18 15:16:43 +01:00
parent 01fc63fc98
commit 14f2522c3e
3 changed files with 8 additions and 5 deletions

View File

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

View File

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

View File

@ -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}`;