loguru: Logging error in Loguru Handler: TypeError: __init__() missing 1 required positional argument: 'message'
Hello,
i am getting the following error message sometimes which makes me assume that somewhere in my application i am writing None the logger.
--- Logging error in Loguru Handler #2 ---
Record was: None
Traceback (most recent call last):
File "/home/.../lib/python3.8/site-packages/loguru/_handler.py", line 265, in _queued_writer
message = queue.get()
File "/home/.../lib/python3.8/multiprocessing/queues.py", line 358, in get
return _ForkingPickler.loads(res)
TypeError: __init__() missing 1 required positional argument: 'message'
--- End of logging error ---
A review did not yield the place where it happens.
So i wonder how could i find out the place which writes a None to the logger…
The traceback is decoupled from the place where the message gets put, so i am searching for the correct place where i should put the check for a possible None.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 22 (10 by maintainers)
Commits related to this issue
- Fix errors due to non-unpicklable Exception when "enqueue=True" (#329) — committed to Delgan/loguru by Delgan 10 months ago
- chore(deps): update dependency loguru to v0.7.2 (#108) [](https://renovatebot.com) This PR contains the following updates: | Pack... — committed to dqx-translation-project/dqxclarity by renovate[bot] 9 months ago
Hi. Which
loguruversion are you using please?The
Record was: Noneerror message is tricky. It actually means thatloguruwas unable to retrieve therecordobject at the time the error occurred. It happens only in one case: while trying to callqueue.get()to retrieve the logged message. See here: https://github.com/Delgan/loguru/blob/b77f4fd23ac380fa2521dd2039c961af1218d1d1/loguru/_handler.py#L268-L274The error happens because when
enqueue=True, therecordneeds to be serialized and deserialized usingpickle. If therecordcontains object which can’t be deserialized, the message will not be logged. Such exception is likely related to custom elements added to therecord["extra"]dict while callinglogger.bind()or, more recently, when using**kwargsinlogger.info("Message", foo=my_object).Can you spot somewhere in your code places where non-trivial objects are logged?