diff --git a/lib/config/config_settings.h b/lib/config/config_settings.h index f56ff7b85..59e890811 100644 --- a/lib/config/config_settings.h +++ b/lib/config/config_settings.h @@ -859,7 +859,10 @@ cfg(log_report_command_log_CFG, "report_command_log", log_CFG_SECTION, CFG_PROFI "option. Use log/command_log_cols and log/command_log_sort settings\n" "to define fields to display and sort fields for the log report.\n" "You can also use log/command_log_selection to define selection\n" - "criteria used each time the log is reported.\n") + "criteria used each time the log is reported.\n" + "Note that if report/output_format (or --reporformat command line\n" + "option) is set to json or json_std, then log/report_command_log=1\n" + "is default.\n") cfg(log_command_log_sort_CFG, "command_log_sort", log_CFG_SECTION, CFG_PROFILABLE | CFG_DEFAULT_COMMENTED | CFG_DISALLOW_INTERACTIVE, CFG_TYPE_STRING, DEFAULT_COMMAND_LOG_SORT, vsn(2, 2, 158), NULL, 0, NULL, "List of columns to sort by when reporting command log.\n" @@ -1853,8 +1856,8 @@ cfg(report_output_format_CFG, "output_format", report_CFG_SECTION, CFG_PROFILABL " Compared to original \"json\" format:\n" " - it does not use double quotes around numeric values,\n" " - it uses 'null' for undefined numeric values,\n" - " - it prints string list as proper JSON array of strings instead of a single string." - "\n") + " - it prints string list as proper JSON array of strings instead of a single string.\n" + "Note that if json or json_std output format is used, then log/command_log_report=1 is default.\n") cfg(report_compact_output_CFG, "compact_output", report_CFG_SECTION, CFG_PROFILABLE | CFG_DEFAULT_COMMENTED, CFG_TYPE_BOOL, DEFAULT_REP_COMPACT_OUTPUT, vsn(2, 2, 115), NULL, 0, NULL, "Do not print empty values for all report fields.\n" diff --git a/tools/reporter.c b/tools/reporter.c index 6bba239f0..732688c30 100644 --- a/tools/reporter.c +++ b/tools/reporter.c @@ -1490,6 +1490,7 @@ int report_format_init(struct cmd_context *cmd) int config_set = find_config_tree_node(cmd, report_output_format_CFG, NULL) != NULL; const char *config_format_str = find_config_tree_str(cmd, report_output_format_CFG, NULL); const char *format_str = arg_str_value(cmd, reportformat_ARG, config_set ? config_format_str : NULL); + int report_command_log_config_set = find_config_tree_node(cmd, log_report_command_log_CFG, NULL) != NULL; int report_command_log; struct report_args args = {0}; struct single_report_args *single_args; @@ -1504,8 +1505,12 @@ int report_format_init(struct cmd_context *cmd) : DM_REPORT_GROUP_SINGLE; } else if (!strcmp(format_str, REPORT_FORMAT_NAME_JSON)) { args.report_group_type = DM_REPORT_GROUP_JSON; + if (!report_command_log_config_set) + report_command_log = 1; } else if (!strcmp(format_str, REPORT_FORMAT_NAME_JSON_STD)) { args.report_group_type = DM_REPORT_GROUP_JSON_STD; + if (!report_command_log_config_set) + report_command_log = 1; } else { log_error("%s: unknown report format.", format_str); log_error("Supported report formats: %s, %s, %s.",