root: re-use custom log helper from config and cleanup duplicate functions

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer
2022-09-10 13:24:31 +02:00
parent aabb8af486
commit 28835fbca7
3 changed files with 16 additions and 49 deletions

View File

@ -3,10 +3,7 @@
import importlib
import logging
import os
import sys
from hashlib import sha512
from json import dumps
from time import time
from urllib.parse import quote_plus
import structlog
@ -20,20 +17,6 @@ from authentik.lib.sentry import sentry_init
from authentik.lib.utils.reflection import get_env
from authentik.stages.password import BACKEND_APP_PASSWORD, BACKEND_INBUILT, BACKEND_LDAP
def j_print(event: str, log_level: str = "info", **kwargs):
"""Print event in the same format as structlog with JSON.
Used before structlog is configured."""
data = {
"event": event,
"level": log_level,
"logger": __name__,
"timestamp": time(),
}
data.update(**kwargs)
print(dumps(data), file=sys.stderr)
LOGGER = structlog.get_logger()
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
@ -484,4 +467,4 @@ if DEBUG:
INSTALLED_APPS.append("authentik.core")
j_print("Booting authentik", version=__version__)
CONFIG.log("info", "Booting authentik", version=__version__)