mirror of
git://sourceware.org/git/lvm2.git
synced 2024-10-05 12:19:48 +03:00
config: use default log/command_log_report=1 for json/json_std output format
log/command_log_report config setting defaults to 1 now if json or json_std output format is used (either by setting report/output_format config setting or using --reportformat cmd line arg). This means that if we use json/json_std output format, the command log messages are then part of the json output too, not interleaved as unstructured text mixed with the json output. If log/command_log_report is set explicitly in the config, then we still respect that, no matter what output format is used currently. In this case, users can still separate and redirect the output by using LVM_OUT_FD, LVM_ERR_FD and LVM_REPORT_FD so that the different types do not interleave with the json/json_std output.
This commit is contained in:
parent
be229b0cd1
commit
8281f7c111
@ -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"
|
||||
|
@ -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.",
|
||||
|
Loading…
Reference in New Issue
Block a user