root: ensure manual loggers also have timestamp
This commit is contained in:
parent
dda1217735
commit
5faafbbca6
|
@ -3,7 +3,7 @@
|
|||
import passbook. This is done by the dockerfile."""
|
||||
from json import dumps
|
||||
from sys import stderr
|
||||
from time import sleep
|
||||
from time import sleep, time
|
||||
|
||||
from psycopg2 import OperationalError, connect
|
||||
from redis import Redis
|
||||
|
@ -19,6 +19,7 @@ def j_print(event: str, log_level: str = "info", **kwargs):
|
|||
"event": event,
|
||||
"level": log_level,
|
||||
"logger": __name__,
|
||||
"timestamp": time(),
|
||||
}
|
||||
data.update(**kwargs)
|
||||
print(dumps(data), file=stderr)
|
||||
|
|
|
@ -4,6 +4,7 @@ from collections.abc import Mapping
|
|||
from contextlib import contextmanager
|
||||
from glob import glob
|
||||
from json import dumps
|
||||
from time import time
|
||||
from typing import Any, Dict
|
||||
from urllib.parse import urlparse
|
||||
|
||||
|
@ -60,7 +61,12 @@ class ConfigLoader:
|
|||
def _log(self, level: str, message: str, **kwargs):
|
||||
"""Custom Log method, we want to ensure ConfigLoader always logs JSON even when
|
||||
'structlog' or 'logging' hasn't been configured yet."""
|
||||
output = {"event": message, "level": level, "logger": self.__class__.__module__}
|
||||
output = {
|
||||
"event": message,
|
||||
"level": level,
|
||||
"logger": self.__class__.__module__,
|
||||
"timestamp": time(),
|
||||
}
|
||||
output.update(kwargs)
|
||||
print(dumps(output))
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ import importlib
|
|||
import os
|
||||
import sys
|
||||
from json import dumps
|
||||
from time import time
|
||||
|
||||
import structlog
|
||||
from celery.schedules import crontab
|
||||
|
@ -36,6 +37,7 @@ def j_print(event: str, log_level: str = "info", **kwargs):
|
|||
"event": event,
|
||||
"level": log_level,
|
||||
"logger": __name__,
|
||||
"timestamp": time(),
|
||||
}
|
||||
data.update(**kwargs)
|
||||
print(dumps(data), file=sys.stderr)
|
||||
|
|
Reference in New Issue