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

Color log formatter #1247

Merged
merged 5 commits into from
Mar 11, 2024
Merged

Color log formatter #1247

merged 5 commits into from
Mar 11, 2024

Conversation

grimoire
Copy link
Collaborator

@grimoire grimoire commented Mar 5, 2024

  • log level name would be colored.
  • add timer to key function in pytorch engine.

DEBUG mode could be enabled by:

logger = get_logger('lmdeploy')
logger.setLevel(logging.DEBUG)
for handler in logger.handlers:
    handler.setLevel(logging.DEBUG)

step logs in DEBUG mode:

2024-03-05 15:45:32,977 - lmdeploy - DEBUG - <ScheduleDecoding> take time: 0.01 ms
2024-03-05 15:45:32,977 - lmdeploy - DEBUG - <AsyncStep>: batch_size=1
2024-03-05 15:45:32,977 - lmdeploy - DEBUG - <CreateModelInputs> take time: 0.08 ms
2024-03-05 15:45:32,997 - lmdeploy - DEBUG - <ModelForward> take time: 19.69 ms
2024-03-05 15:45:32,998 - lmdeploy - DEBUG - <SamplingLogits> take time: 1.55 ms
2024-03-05 15:45:32,999 - lmdeploy - DEBUG - <UpdateRunning> take time: 0.04 ms
2024-03-05 15:45:32,999 - lmdeploy - DEBUG - <AsyncStep> take time: 21.76 ms

color table:

    _LEVELNAME_COLOR_MAP = dict(CRITICAL='\033[91m',    # dark red
                                ERROR='\033[31m',    # red
                                WARN='\033[33m',    # yellow
                                WARNING='\033[33m',    # yellow
                                INFO='\033[37m',    # white
                                DEBUG='\033[32m',    # green
)

@lvhan028 lvhan028 requested a review from RunningLeon March 11, 2024 02:15
lmdeploy/utils.py Outdated Show resolved Hide resolved
lmdeploy/utils.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@RunningLeon RunningLeon left a comment

Choose a reason for hiding this comment

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

LGTM

@lvhan028 lvhan028 merged commit 42f94c5 into InternLM:main Mar 11, 2024
3 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants