Merge branch 'feat/monitor_auto_color' into 'master'

feat(tools): Add auto color to monitor and disable colors from chip logs

Closes IDF-362 and DOC-9110

See merge request espressif/esp-idf!33623
This commit is contained in:
Martin Vychodil
2024-10-11 01:04:26 +08:00
7 changed files with 19 additions and 7 deletions

View File

@ -2,7 +2,7 @@ menu "Format"
config BOOTLOADER_LOG_COLORS
bool "Color"
default y
default n
help
Use ANSI terminal colors in log output
Enable ANSI terminal color codes.

View File

@ -2,7 +2,7 @@ menu "Format"
config LOG_COLORS
bool "Color"
default y
default n
help
Enable ANSI terminal color codes.
In order to view these, your terminal program must support ANSI color codes.

View File

@ -8,6 +8,7 @@ Log
- `esp_log_buffer_hex` is deprecated, use `ESP_LOG_BUFFER_HEX` instead.
- `esp_log_buffer_char` is deprecated, use `ESP_LOG_BUFFER_CHAR` instead.
- The default value for ``CONFIG_LOG_COLORS`` is now set to false. Colors are added on the host side by default in IDF Monitor. If you want to enable colors in the log output for other console monitors, set ``CONFIG_LOG_COLORS`` to true in your project configuration. To disable automatic coloring in IDF Monitor, run the following command: ``idf.py monitor --disable-auto-color``.
ESP ROM
---------

View File

@ -8,6 +8,7 @@
- `esp_log_buffer_hex` 已弃用,应使用 `ESP_LOG_BUFFER_HEX` 替代。
- `esp_log_buffer_char` 已弃用,应使用 `ESP_LOG_BUFFER_CHAR` 替代。
- ``CONFIG_LOG_COLORS`` 的默认值设置为 false。默认情况下IDF Monitor 在主机端添加颜色。如需在其他控制台监视器的日志输出中启用颜色,请将 ``CONFIG_LOG_COLORS`` 设置为 true。如需在 IDF Monitor 中关闭自动的日志颜色显示,请运行命令: ``idf.py monitor --disable-auto-color``
ESP ROM
---------

View File

@ -97,7 +97,7 @@ There are two outputs produced by example:
```
W (274) example: Switch to semihosted stdout
W (274) example: Switched back to UART stdout
I (274) example: Wrote 2798 bytes
I (274) example: Wrote 2776 bytes
====================== HOST DATA START =========================
The following are the graphical (non-control) characters defined by
ISO 8859-1 (1987). Descriptions in words aren't all that helpful,
@ -115,4 +115,3 @@ There are two outputs produced by example:
====================== HOST DATA END =========================
I (694) example: Read 6121 bytes
```

View File

@ -1,6 +1,5 @@
# SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
# SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Unlicense OR CC0-1.0
import os
import shutil
import tempfile
@ -42,7 +41,10 @@ def prepare() -> t.Generator[None, None, None]:
def test_semihost_vfs(dut: IdfDut) -> None:
dut.expect_exact('example: Switch to semihosted stdout')
dut.expect_exact('example: Switched back to UART stdout')
dut.expect_exact('example: Wrote 2798 bytes')
if dut.app.sdkconfig.get('LOG_COLORS') is True:
dut.expect_exact('example: Wrote 2798 bytes')
else:
dut.expect_exact('example: Wrote 2776 bytes')
dut.expect_exact('====================== HOST DATA START =========================')
with open(HOST_FILE_PATH) as f:

View File

@ -105,6 +105,7 @@ def action_extensions(base_actions: Dict, project_path: str) -> Dict:
timestamps: bool,
timestamp_format: str,
force_color: bool,
disable_auto_color: bool,
) -> None:
"""
Run esp_idf_monitor to watch build output
@ -187,6 +188,9 @@ def action_extensions(base_actions: Dict, project_path: str) -> Dict:
if force_color or os.name == 'nt':
monitor_args += ['--force-color']
if disable_auto_color:
monitor_args += ['--disable-auto-color']
idf_py = [PYTHON] + _get_commandline_options(ctx) # commands to re-run idf.py
monitor_args += ['-m', ' '.join("'%s'" % a for a in idf_py)]
hints = not args.no_hints
@ -1011,6 +1015,11 @@ def action_extensions(base_actions: Dict, project_path: str) -> Dict:
'is_flag': True,
'help': 'Always print ANSI for colors',
},
{
'names': ['--disable-auto-color'],
'is_flag': True,
'help': 'Disable auto coloring logs',
},
],
'order_dependencies': [
'flash',