10
0

Merge branch 'master' of git.k-space.ee:k-space/mongo-logger

This commit is contained in:
Lauri Võsandi 2021-06-30 14:41:23 +00:00
commit 560717fc2b

View File

@ -33,9 +33,13 @@ class Server(object):
async def _handle_request(self, obj, writer: asyncio.StreamWriter) -> None:
tag, time, record, options = obj
seconds, nanoseconds = struct.unpack(">II", time.data)
try:
seconds, nanoseconds = struct.unpack(">II", time.data)
record["time"] = datetime.fromtimestamp(seconds).replace(microsecond=int(nanoseconds/1000))
except AttributeError:
record["time"] = datetime.fromtimestamp(time)
assert not options, "Can't handle options"
record["time"] = datetime.fromtimestamp(seconds).replace(microsecond=int(nanoseconds/1000))
record.pop("container_id", None)
record["host"] = FQDN
result = await db.log.insert_one(record)