The module is not reported correctly on handled records
Opened this issue · 1 comments
pamelafox commented
I noticed this issue while working on the QueueHandler.
The following test succeeds with CPython logging but fails with picologging:
def test_queue_handler_dispatch():
logger = picologging.Logger("test", picologging.DEBUG)
q = queue.Queue()
handler = QueueHandler(q)
logger.addHandler(handler)
logger.debug("test")
record = q.get(block=False)
assert record.module == "test_queuehandler"
In picologging, the module is reported as simply "python" instead. I haven't dug in yet to see where the problem is.
aminalaee commented
Trying the above example results in:
assert record.module == "python"
assert record.filename == "python.py"
which is coming from https://github.com/pytest-dev/pytest/blob/main/src/_pytest/python.py not sure why.
But interestingly if you try this:
# example.py file
import queue
import picologging
from picologging.handlers import QueueHandler, QueueListener
logger = picologging.Logger("test", picologging.DEBUG)
q = queue.Queue()
handler = QueueHandler(q)
logger.addHandler(handler)
logger.debug("test")
logger.debug("test")
q.get(block=False)
record = q.get(block=False)
assert record.filename == "<unknown>"
assert record.module == "<unknown>"
I think it has something to do how frames objects are accessed. I will create a temporary PR to see how it can fix the <unkown>
issue.