diff --git a/logger.py b/logger.py index 1811850..c769ea8 100755 --- a/logger.py +++ b/logger.py @@ -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)