RT-Thread / RT-Thread/rt-thread

[Bug] 使用带颜色的日志输出后不能恢复默认颜色问题

Open
#11,296 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
12.2k
Forks
5.4k
Avg merge
4d 12h
Merged PRs (30d)
40

Description

RT-Thread Version

master

Hardware Type/Architectures

ulog

Develop Toolchain

GCC

Describe the bug

1.问题现象:ulog_tail_formater中的颜色结尾顺序是:先换行,再颜色结束码“[日志内容][换行][CSI_END]”。
这会导致:输出到终端后, CSI_END 在新行开头,而下一行是 shell 提示符,所以提示符并没有恢复默认颜色。
正确顺序应该是:[日志内容][CSI_END][换行]。
2.解决办法:原ulog.c文件404行至408行移至417行。

Image

Other additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in ulog.c, focusing on ulog_tail_formater and the referenced lines 404-408 and 417. Inspect the terminal color escape ordering, adjust the sequence as described in the issue, and verify that subsequent shell prompts use the default color after colored log output.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
embedded-iot
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.