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

[BUG] Log warning in sublime text #3119

Closed
Erimus-Koo opened this issue Sep 3, 2023 · 5 comments
Closed

[BUG] Log warning in sublime text #3119

Erimus-Koo opened this issue Sep 3, 2023 · 5 comments

Comments

@Erimus-Koo
Copy link

Describe the bug

  • I have two files: rich_log.py and config.py.
  • In rich_log, I set up a logger and run a build in Sublime Text, everything is good.
  • In config, I import the log from rich_log and then run it, but there's a warning message.
image

rich_log.py

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import logging
import os

from rich.logging import RichHandler


def set_log(logger_name='rich') -> logging.Logger:
    logger = logging.getLogger(logger_name)
    logger.setLevel(logging.DEBUG)

    # rich handler
    rh = RichHandler()
    logger.addHandler(rh)

    # file handler
    # ...

    return logger

log = set_log(__name__)


if __name__ == '__main__':

    from rich import inspect
    inspect(log)
    log.debug("Log message")
    log.info("Log message")
    log.error("Log message")
    log.warning("Log message")
    log.critical("Log message")

The file builds without any warnings in Sublime Text.

config.py

from rich_log import set_log, test_log

from rich import inspect

log = set_log()
inspect(log)
log.debug("Log message")
log.info("Log message")
log.error("Log message")
log.warning("Log message")
log.critical("Log message")
image

Platform

  • MacOS
  • SublimeText 4152
  • Python 3.11
  • rich 12.6.0
@github-actions
Copy link

github-actions bot commented Sep 3, 2023

Thank you for your issue. Give us a little time to review it.

PS. You might want to check the FAQ if you haven't done so already.

This is an automated reply, generated by FAQtory

@Erimus-Koo
Copy link
Author

I noticed that when I added rh = RichHandler(show_time=False) in rich_log.py, it caused a change in the warning message in config.py. This leads me to believe that there may be something related to the rich library.

image

@Erimus-Koo
Copy link
Author

And if I set a logger from logging, there's no warning.

# rich_log.py
log1 = logging.getLogger()
# config.py
from utils.logging_lite import set_log, log1
image

Does "rich" do something special or return something?

@willmcgugan
Copy link
Collaborator

Nothing to do with Rich. It is something your editor is doing.

@github-actions
Copy link

github-actions bot commented Sep 3, 2023

I hope we solved your problem.

If you like using Rich, you might also enjoy Textual

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants