Skip to content

Commit

Permalink
Use dict literal entirely while serializing record
Browse files Browse the repository at this point in the history
  • Loading branch information
Delgan committed Mar 31, 2019
1 parent 00342bb commit cac17f3
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions loguru/_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,26 +173,34 @@ def levelno(self):

@staticmethod
def _serialize_record(text, record):
exc = record["exception"]
serializable = {
"text": text,
"record": {
"elapsed": dict(repr=record["elapsed"], seconds=record["elapsed"].total_seconds()),
"exception": exc
and dict(type=exc.type.__name__, value=exc.value, traceback=bool(exc.traceback)),
"elapsed": {
"repr": record["elapsed"],
"seconds": record["elapsed"].total_seconds(),
},
"exception": record["exception"]
and {
"type": record["exception"].type.__name__,
"value": record["exception"].value,
"traceback": bool(record["exception"].traceback),
},
"extra": record["extra"],
"file": dict(name=record["file"].name, path=record["file"].path),
"file": {"name": record["file"].name, "path": record["file"].path},
"function": record["function"],
"level": dict(
icon=record["level"].icon, name=record["level"].name, no=record["level"].no
),
"level": {
"icon": record["level"].icon,
"name": record["level"].name,
"no": record["level"].no,
},
"line": record["line"],
"message": record["message"],
"module": record["module"],
"name": record["name"],
"process": dict(id=record["process"].id, name=record["process"].name),
"thread": dict(id=record["thread"].id, name=record["thread"].name),
"time": dict(repr=record["time"], timestamp=record["time"].timestamp()),
"process": {"id": record["process"].id, "name": record["process"].name},
"thread": {"id": record["thread"].id, "name": record["thread"].name},
"time": {"repr": record["time"], "timestamp": record["time"].timestamp()},
},
}

Expand Down

0 comments on commit cac17f3

Please sign in to comment.