From da978bc5a12f7a1b6652863ea724b0c716ad2832 Mon Sep 17 00:00:00 2001 From: Roland Dobai Date: Mon, 4 Mar 2019 16:25:42 +0100 Subject: [PATCH] tools: Port the filtering option of IDF Monitor to the idf.py toolchain --- docs/en/api-guides/tools/idf-monitor.rst | 2 +- docs/zh_CN/api-guides/tools/idf-monitor.rst | 2 +- tools/idf.py | 25 +++++++++++++++++---- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/docs/en/api-guides/tools/idf-monitor.rst b/docs/en/api-guides/tools/idf-monitor.rst index f48275d8fb..2718a0adc5 100644 --- a/docs/en/api-guides/tools/idf-monitor.rst +++ b/docs/en/api-guides/tools/idf-monitor.rst @@ -115,7 +115,7 @@ In the background, IDF Monitor runs the following command:: Output Filtering ~~~~~~~~~~~~~~~~ -IDF monitor can be invoked as ``make monitor PRINT_FILTER=""`` (for make) or ``idf.py monitor PRINT_FILTER=""`` (for cmake), where ``PRINT_FILTER`` is the parameter for output filtering. The default value is an empty string, which means that everything is printed. +IDF monitor can be invoked as ``make monitor PRINT_FILTER=""`` (for make) or ``idf.py monitor --print-filter=""`` (for cmake), where ``PRINT_FILTER`` is the parameter for output filtering. The default value is an empty string, which means that everything is printed. Restrictions on what to print can be specified as a series of ``:`` items where ```` is the tag string and ```` is a character from the set ``{N, E, W, I, D, V, *}`` referring to a level for :doc:`logging <../../api-reference/system/log>`. diff --git a/docs/zh_CN/api-guides/tools/idf-monitor.rst b/docs/zh_CN/api-guides/tools/idf-monitor.rst index 3d842fbd13..c47a071708 100644 --- a/docs/zh_CN/api-guides/tools/idf-monitor.rst +++ b/docs/zh_CN/api-guides/tools/idf-monitor.rst @@ -103,7 +103,7 @@ IDF 监控器在后台运行如下命令:: 输出筛选 ~~~~~~~~~~~~~~~~ -IDF 监视器有两种启用方式:运行 ``make monitor PRINT_FILTER=""`` (适用于 Make)或者 ``idf.py monitor PRINT_FILTER=""`` (适用于 CMake),其中,``PRINT_FILTER`` 是输出筛选的参数。参数默认值为空字符串,可打印任何内容。 +IDF 监视器有两种启用方式:运行 ``make monitor PRINT_FILTER=""`` (适用于 Make)或者 ``idf.py monitor --print-filter=""`` (适用于 CMake),其中,``PRINT_FILTER`` 是输出筛选的参数。参数默认值为空字符串,可打印任何内容。 若需对打印内容设置限制,可指定 ``:`` 等选项,其中 ```` 是标签字符串,```` 是 ``{N, E, W, I, D, V, *}`` 集合中的一个字母,指的是 :doc:`日志 <../../api-reference/system/log>` 级别。 diff --git a/tools/idf.py b/tools/idf.py index cdaf84ecd0..abcdfc8701 100755 --- a/tools/idf.py +++ b/tools/idf.py @@ -361,7 +361,7 @@ def erase_flash(action, ctx, args): _run_tool("esptool.py", esptool_args, args.build_dir) -def monitor(action, ctx, args): +def monitor(action, ctx, args, print_filter): """ Run idf_monitor.py to watch build output """ @@ -385,6 +385,8 @@ def monitor(action, ctx, args): if args.port is not None: monitor_args += ["-p", args.port] monitor_args += ["-b", project_desc["monitor_baud"]] + if print_filter is not None: + monitor_args += ["--print_filter", print_filter] monitor_args += [elf_file] idf_py = [PYTHON] + get_commandline_options(ctx) # commands to re-run idf.py @@ -920,7 +922,7 @@ def init_cli(): }, "show_efuse_table": { "callback": build_target, - "help": "Print eFuse table", + "help": "Print eFuse table.", "order_dependencies": ["reconfigure"], }, "partition_table": { @@ -986,7 +988,7 @@ def init_cli(): "actions": { "flash": { "callback": flash, - "help": "Flash the project", + "help": "Flash the project.", "dependencies": ["all"], "order_dependencies": ["erase_flash"], }, @@ -997,6 +999,22 @@ def init_cli(): "monitor": { "callback": monitor, "help": "Display serial output.", + "options": [ + { + "names": ["--print-filter", "--print_filter"], + "help": ( + "Filter monitor output.\n" + "Restrictions on what to print can be specified as a series of : items " + "where is the tag string and is a character from the set " + "{N, E, W, I, D, V, *} referring to a level. " + 'For example, "tag1:W" matches and prints only the outputs written with ' + 'ESP_LOGW("tag1", ...) or at lower verbosity level, i.e. ESP_LOGE("tag1", ...). ' + 'Not specifying a or using "*" defaults to Verbose level.\n' + 'Please see the IDF Monitor section of the ESP-IDF documentation ' + 'for a more detailed description and further examples.'), + "default": None, + }, + ], "order_dependencies": [ "flash", "partition_table-flash", @@ -1042,7 +1060,6 @@ def init_cli(): ) # Add actions extensions - try: all_actions.append(action_extensions(base_actions, project_dir)) except NameError: