events: improve logging for geoip
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
01fc63fc98
commit
14f2522c3e
|
@ -1,11 +1,13 @@
|
||||||
"""events GeoIP Reader"""
|
"""events GeoIP Reader"""
|
||||||
|
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
from geoip2.database import Reader
|
from geoip2.database import Reader
|
||||||
|
from structlog.stdlib import get_logger
|
||||||
|
|
||||||
from authentik.lib.config import CONFIG
|
from authentik.lib.config import CONFIG
|
||||||
|
|
||||||
|
LOGGER = get_logger()
|
||||||
|
|
||||||
|
|
||||||
def get_geoip_reader() -> Optional[Reader]:
|
def get_geoip_reader() -> Optional[Reader]:
|
||||||
"""Get GeoIP Reader, if configured, otherwise none"""
|
"""Get GeoIP Reader, if configured, otherwise none"""
|
||||||
|
@ -13,7 +15,9 @@ def get_geoip_reader() -> Optional[Reader]:
|
||||||
if path == "" or not path:
|
if path == "" or not path:
|
||||||
return None
|
return None
|
||||||
try:
|
try:
|
||||||
return Reader(path)
|
reader = Reader(path)
|
||||||
|
LOGGER.info("Enabled GeoIP support")
|
||||||
|
return reader
|
||||||
except OSError:
|
except OSError:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
|
@ -156,8 +156,8 @@ class Event(models.Model):
|
||||||
}
|
}
|
||||||
if response.city.name:
|
if response.city.name:
|
||||||
self.context["geo"]["city"] = response.city.name
|
self.context["geo"]["city"] = response.city.name
|
||||||
except GeoIP2Error:
|
except GeoIP2Error as exc:
|
||||||
pass
|
LOGGER.warning("Failed to add geoIP Data to event", exc=exc)
|
||||||
|
|
||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
if self._state.adding:
|
if self._state.adding:
|
||||||
|
|
|
@ -46,7 +46,6 @@ export class RouterOutlet extends LitElement {
|
||||||
updated(): void {
|
updated(): void {
|
||||||
if (!this.shadowRoot) return;
|
if (!this.shadowRoot) return;
|
||||||
Array.from(this.shadowRoot?.children).forEach((el) => {
|
Array.from(this.shadowRoot?.children).forEach((el) => {
|
||||||
console.log("pageTitle" in el);
|
|
||||||
if ("pageTitle" in el) {
|
if ("pageTitle" in el) {
|
||||||
const title = (el as Page).pageTitle();
|
const title = (el as Page).pageTitle();
|
||||||
document.title = `${title} - ${TITLE_SUFFIX}`;
|
document.title = `${title} - ${TITLE_SUFFIX}`;
|
||||||
|
|
Reference in New Issue