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

When import telegramify_markdown, the log record is invalid. #53

Closed
finn-chan opened this issue Dec 27, 2024 · 3 comments · Fixed by #54
Closed

When import telegramify_markdown, the log record is invalid. #53

finn-chan opened this issue Dec 27, 2024 · 3 comments · Fixed by #54
Labels
bug Something isn't working logging question Further information is requested

Comments

@finn-chan
Copy link

I set up logging in the program:

if settings.LOG_ENABLED:
    log_dir = os.path.dirname(settings.LOG_FILE_PATH)
    os.makedirs(log_dir, exist_ok=True)

    logging.basicConfig(
        level=logging.INFO,
        format='%(asctime)s - %(levelname)s - %(message)s',
        handlers=[
            logging.FileHandler(settings.LOG_FILE_PATH, mode='a'),
            logging.StreamHandler()
        ]
    )

I found that after I imported this library, I couldn't log to the file (but I could see the log content in the console).

Even if I block it, it still affects the log.

logging.getLogger('telegramify_markdown').setLevel(logging.CRITICAL)

How can I set it up?

@neutron-nerve neutron-nerve bot added bug Something isn't working question Further information is requested logging labels Dec 27, 2024
@sudoskys
Copy link
Owner

sudoskys commented Dec 27, 2024

Hmm seems to be causing some problems. I will remove the logger in the next version

Before that, you can import

telegramify_markdown.logger.logger to set it

https://github.com/sudoskys/telegramify-markdown/blob/main/src/telegramify_markdown/logger.py

@sudoskys sudoskys linked a pull request Jan 3, 2025 that will close this issue
Copy link

neutron-nerve bot commented Jan 3, 2025

Issue Report: Invalid Log Record upon Importing telegramify_markdown

Issue Overview

An issue was reported regarding the telegramify_markdown library affecting the logging system of the importing program. Specifically, after importing telegramify_markdown, log entries were not being recorded to a file as intended, although they appeared in the console. The attempt to adjust the log levels for the telegramify_markdown library using:

logging.getLogger('telegramify_markdown').setLevel(logging.CRITICAL)

did not resolve the issue.

Root Cause

The problem stemmed from the internal logger configuration within the telegramify_markdown library, which interfered with the existing logging setup of the main application.

Proposed Solution

The project maintainer, @sudoskys, acknowledged the issue and planned to remove the logger in the subsequent version of the library. As an interim solution, users were advised to manually adjust the logging settings by directly importing the library's logger:

import telegramify_markdown.logger.logger

This approach allowed users to reconfigure or disable the logger in a manner that harmonizes well with their own logging setups.

Final Outcome

The issue was formally closed on January 3, 2025, following the proposed interim workaround and the commitment to remove the conflicting logger in future iterations of the library.

Acknowledgments

We express our gratitude to @finn-chan for identifying the issue and to @sudoskys for providing a timely workaround and planning a permanent resolution.

@sudoskys
Copy link
Owner

sudoskys commented Jan 3, 2025

We changed the logger to loguru global logger which is easier to configure.

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

Successfully merging a pull request may close this issue.

2 participants