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

Most upvoted comments

Hi. Which loguru version are you using please?

The Record was: None error message is tricky. It actually means that loguru was unable to retrieve the record object at the time the error occurred. It happens only in one case: while trying to call queue.get() to retrieve the logged message. See here: https://github.com/Delgan/loguru/blob/b77f4fd23ac380fa2521dd2039c961af1218d1d1/loguru/_handler.py#L268-L274

The error happens because when enqueue=True, the record needs to be serialized and deserialized using pickle. If the record contains object which can’t be deserialized, the message will not be logged. Such exception is likely related to custom elements added to the record["extra"] dict while calling logger.bind() or, more recently, when using **kwargs in logger.info("Message", foo=my_object).

Can you spot somewhere in your code places where non-trivial objects are logged?