mirror of
git://sourceware.org/git/lvm2.git
synced 2025-02-14 05:57:54 +03:00
conf: add report/output_format config setting
New report/output_format configuration sets the output format used for all LVM commands globally. Currently, there are 2 formats recognized: - basic (the classical basic output with columns and rows, used by default) - json (output is in json format)
This commit is contained in:
parent
79a74e9aae
commit
a08e02afbf
@ -1,5 +1,6 @@
|
||||
Version 2.02.158 -
|
||||
=================================
|
||||
Add log/report_output_format to lvm.conf for default report output format.
|
||||
Recognize --reportformat {basic|json} option to select report output format.
|
||||
Add log/command_log_{sort,cols} to lvm.conf to configure command log report.
|
||||
Add log_object_{type,name,id,group,group_id} fields to cmd log.
|
||||
|
@ -1567,6 +1567,16 @@ activation {
|
||||
# This configuration section has an automatic default value.
|
||||
# report {
|
||||
|
||||
# Configuration option report/output_format.
|
||||
# Format of LVM2 command report output.
|
||||
# Accepted values:
|
||||
# basic
|
||||
# Original format with columns and rows.
|
||||
# json
|
||||
# JSON format.
|
||||
# This configuration option has an automatic default value.
|
||||
# output_format = "basic"
|
||||
|
||||
# Configuration option report/compact_output.
|
||||
# Do not print empty values for all report fields.
|
||||
# If enabled, all fields that don't have a value set for any of the
|
||||
|
@ -1474,6 +1474,14 @@ cfg(disk_area_start_sector_CFG, "start_sector", disk_area_CFG_SUBSECTION, CFG_UN
|
||||
cfg(disk_area_size_CFG, "size", disk_area_CFG_SUBSECTION, CFG_UNSUPPORTED | CFG_DEFAULT_COMMENTED, CFG_TYPE_INT, 0, vsn(1, 0, 0), NULL, 0, NULL, NULL)
|
||||
cfg(disk_area_id_CFG, "id", disk_area_CFG_SUBSECTION, CFG_UNSUPPORTED | CFG_DEFAULT_UNDEFINED, CFG_TYPE_STRING, NULL, vsn(1, 0, 0), NULL, 0, NULL, NULL)
|
||||
|
||||
cfg(report_output_format_CFG, "output_format", report_CFG_SECTION, CFG_PROFILABLE | CFG_DEFAULT_COMMENTED, CFG_TYPE_STRING, DEFAULT_REP_OUTPUT_FORMAT, vsn(2, 2, 158), NULL, 0, NULL,
|
||||
"Format of LVM2 command report output.\n"
|
||||
"Accepted values:\n"
|
||||
" basic\n"
|
||||
" Original format with columns and rows.\n"
|
||||
" json\n"
|
||||
" JSON format.\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"
|
||||
"If enabled, all fields that don't have a value set for any of the\n"
|
||||
|
@ -207,6 +207,7 @@
|
||||
#define DEFAULT_REP_LIST_ITEM_SEPARATOR ","
|
||||
#define DEFAULT_TIME_FORMAT "%Y-%m-%d %T %z"
|
||||
|
||||
#define DEFAULT_REP_OUTPUT_FORMAT "basic"
|
||||
#define DEFAULT_COMPACT_OUTPUT_COLS ""
|
||||
|
||||
#define DEFAULT_LVS_COLS "lv_name,vg_name,lv_attr,lv_size,pool_lv,origin,data_percent,metadata_percent,move_pv,mirror_log,copy_percent,convert_lv"
|
||||
|
@ -1070,7 +1070,9 @@ int report_format_init(struct cmd_context *cmd, dm_report_group_type_t *report_g
|
||||
struct dm_report_group **report_group, struct dm_report **log_rh)
|
||||
{
|
||||
static char log_report_name[] = "log";
|
||||
const char *format_str = arg_str_value(cmd, reportformat_ARG, NULL);
|
||||
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);
|
||||
struct report_args args = {0};
|
||||
struct dm_report_group *new_report_group;
|
||||
struct dm_report *tmp_log_rh = NULL;
|
||||
|
Loading…
x
Reference in New Issue
Block a user