Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot disable loguru in cython build #875

Closed
senysenyseny16 opened this issue May 22, 2023 · 3 comments
Closed

Cannot disable loguru in cython build #875

senysenyseny16 opened this issue May 22, 2023 · 3 comments
Labels
question Further information is requested

Comments

@senysenyseny16
Copy link

Hi,

I'm using Cython and loguru works but I can't manage (disable) logging:

from loguru import logger

logger.disable(<module_name>)

the above code works for source distribution and doesn't work with the binary (Cythonized) distribution.

Has anyone experienced this behavior?

@Delgan
Copy link
Owner

Delgan commented May 22, 2023

Hi @senysenyseny16.

Cython removes the stack frames, causing Loguru to access the wrong context when a message is logged. Therefore, the logged message is associated with an incorrect module name, and disable() cannot filter it properly.

I'm not aware of any possible workaround, unfortunately. :/

@senysenyseny16
Copy link
Author

hi @Delgan.

Thanks for your reply 🥲

@Delgan Delgan added the question Further information is requested label May 23, 2023
@Delgan
Copy link
Owner

Delgan commented Nov 26, 2024

Note that Cython compatibility with Loguru was improved by #1240.

Using logger.disable(None) should disable logs coming from Cython modules.

The logger.disable() method takes as input the name of the logger to disable (usually a string). Here, None is used because the logger within Cython modules has no name (due to the absence of available stack frame).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants