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

use different colors to distinguish logs #2333

Merged
merged 7 commits into from
Jul 26, 2024
Merged

use different colors to distinguish logs #2333

merged 7 commits into from
Jul 26, 2024

Conversation

EdwardLi-coder
Copy link
Contributor

Description

Use different colors to distinguish logs

Related Issues

[LOGGING-IMPR] Use different colors to distinguish logs #2327

Checklist

  • Is this code covered by new or existing unit tests or integration tests?
  • Did you run make unit_testing and make integration-testing successfully?
  • Do new classes, functions, methods and parameters all have docstrings?
  • Were existing docstrings updated, if necessary?
  • Was external documentation updated, if necessary?

Additional Notes or Comments

"| {extra[hostname]: <8}"
"| {name}:{line: <4} "
"| {message}"
"<green> {time:YYYY-MMM-DD HH:mm:ss.SS}</green>"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be configurable. We had this before, and it made life difficult with our ray deployments.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @blythed.I update it. please review it. Thank you.

Copy link
Collaborator

@blythed blythed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please address the comment.

:param use_colors: Whether to use colors in the log output
"""

default_format: str = (
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't do it like this.
I would add a variable to the config colorize and then in the logging module do one or the other.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

config.py

colorize: bool = True

logging.py

if CFG.logging.colorize:
    message = (
        "<green>{time:YYYY-MMM-DD HH:mm:ss.SS}</green>"
        "| <level>{level: <8}</level> "
        "| <cyan>{extra[hostname]: <8}</cyan>"
        "| <cyan>{name}</cyan>:<cyan>{line: <4}</cyan> "
        f"| <level>{message}</level>"
    )
else:
    message = (
        "{time:YYYY-MMM-DD HH:mm:ss.SS}"
        "| {level: <8} "
        "| {name}:{line: <4} "
        f"| {message}"
    )

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

config.py

colorize: bool = True

logging.py

if CFG.logging.colorize:
    message = (
        "<green>{time:YYYY-MMM-DD HH:mm:ss.SS}</green>"
        "| <level>{level: <8}</level> "
        "| <cyan>{extra[hostname]: <8}</cyan>"
        "| <cyan>{name}</cyan>:<cyan>{line: <4}</cyan> "
        f"| <level>{message}</level>"
    )
else:
    message = (
        "{time:YYYY-MMM-DD HH:mm:ss.SS}"
        "| {level: <8} "
        "| {name}:{line: <4} "
        f"| {message}"
    )

Ok,I have changed

@EdwardLi-coder EdwardLi-coder requested a review from blythed July 26, 2024 02:10
@blythed blythed merged commit ff2564f into superduper-io:main Jul 26, 2024
3 checks passed
@blythed
Copy link
Collaborator

blythed commented Jul 26, 2024

Thanks @EdwardLi-coder!

@EdwardLi-coder EdwardLi-coder deleted the make_log_distinguish branch July 26, 2024 10:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants