k-space
/
mongo-logger
Archived
9
0
Fork 0

Handle lowres timestamps

This commit is contained in:
Lauri Võsandi 2021-06-19 19:25:45 +00:00
parent 51880829f5
commit 391517658f
1 changed files with 6 additions and 2 deletions

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)