diff options
author | Alasdair G Kergon <agk@redhat.com> | 2012-08-25 20:35:48 +0100 |
---|---|---|
committer | Alasdair G Kergon <agk@redhat.com> | 2012-08-25 20:35:48 +0100 |
commit | 438e0050dfed1f8f2d74670a5f7c5e8c8819c777 (patch) | |
tree | 72488758b931b28d8a7f4294c9059a6fdd9db379 /tools/pvscan.c | |
parent | 4047e4dfb16175daec348bf44032c02181bd4c70 (diff) | |
download | lvm2-438e0050dfed1f8f2d74670a5f7c5e8c8819c777.tar.gz lvm2-438e0050dfed1f8f2d74670a5f7c5e8c8819c777.tar.xz lvm2-438e0050dfed1f8f2d74670a5f7c5e8c8819c777.zip |
config: add silent mode
Accept -q as the short form of --quiet.
Suppress non-essential standard output if -q is given twice.
Treat log/silent in lvm.conf as equivalent to -qq.
Review all log_print messages and change some to
log_print_unless_silent.
When silent, the following commands still produce output:
dumpconfig, lvdisplay, lvmdiskscan, lvs, pvck, pvdisplay,
pvs, version, vgcfgrestore -l, vgdisplay, vgs.
[Needs checking.]
Non-essential messages are shifted from log level 4 to log level 5
for syslog and lvm2_log_fn purposes.
Diffstat (limited to 'tools/pvscan.c')
-rw-r--r-- | tools/pvscan.c | 58 |
1 files changed, 26 insertions, 32 deletions
diff --git a/tools/pvscan.c b/tools/pvscan.c index 6c634e35..92873882 100644 --- a/tools/pvscan.c +++ b/tools/pvscan.c @@ -34,7 +34,7 @@ static void _pvscan_display_single(struct cmd_context *cmd, /* short listing? */ if (arg_count(cmd, short_ARG) > 0) { - log_print("%s", pv_dev_name(pv)); + log_print_unless_silent("%s", pv_dev_name(pv)); return; } @@ -64,37 +64,31 @@ static void _pvscan_display_single(struct cmd_context *cmd, } if (is_orphan(pv)) { - log_print("PV %-*s %-*s %s [%s]", - pv_max_name_len, pv_tmp_name, - vg_max_name_len, " ", - pv->fmt ? pv->fmt->name : " ", - display_size(cmd, pv_size(pv))); + log_print_unless_silent("PV %-*s %-*s %s [%s]", + pv_max_name_len, pv_tmp_name, + vg_max_name_len, " ", + pv->fmt ? pv->fmt->name : " ", + display_size(cmd, pv_size(pv))); return; } if (pv_status(pv) & EXPORTED_VG) { strncpy(vg_name_this, pv_vg_name(pv), vg_name_len); - log_print("PV %-*s is in exported VG %s " - "[%s / %s free]", - pv_max_name_len, pv_tmp_name, - vg_name_this, - display_size(cmd, (uint64_t) pv_pe_count(pv) * - pv_pe_size(pv)), - display_size(cmd, (uint64_t) (pv_pe_count(pv) - - pv_pe_alloc_count(pv)) - * pv_pe_size(pv))); + log_print_unless_silent("PV %-*s is in exported VG %s " + "[%s / %s free]", + pv_max_name_len, pv_tmp_name, + vg_name_this, + display_size(cmd, (uint64_t) pv_pe_count(pv) * pv_pe_size(pv)), + display_size(cmd, (uint64_t) (pv_pe_count(pv) - pv_pe_alloc_count(pv)) * pv_pe_size(pv))); return; } sprintf(vg_tmp_name, "%s", pv_vg_name(pv)); - log_print("PV %-*s VG %-*s %s [%s / %s free]", pv_max_name_len, - pv_tmp_name, vg_max_name_len, vg_tmp_name, - pv->fmt ? pv->fmt->name : " ", - display_size(cmd, (uint64_t) pv_pe_count(pv) * - pv_pe_size(pv)), - display_size(cmd, (uint64_t) (pv_pe_count(pv) - - pv_pe_alloc_count(pv)) * - pv_pe_size(pv))); + log_print_unless_silent("PV %-*s VG %-*s %s [%s / %s free]", pv_max_name_len, + pv_tmp_name, vg_max_name_len, vg_tmp_name, + pv->fmt ? pv->fmt->name : " ", + display_size(cmd, (uint64_t) pv_pe_count(pv) * pv_pe_size(pv)), + display_size(cmd, (uint64_t) (pv_pe_count(pv) - pv_pe_alloc_count(pv)) * pv_pe_size(pv))); } static int _auto_activation_handler(struct volume_group *vg, int partial, @@ -223,8 +217,8 @@ static int _pvscan_lvmetad(struct cmd_context *cmd, int argc, char **argv) break; } - log_print("Device %s not found. " - "Cleared from lvmetad cache.", buf ? : ""); + log_print_unless_silent("Device %s not found. " + "Cleared from lvmetad cache.", buf ? : ""); if (buf) dm_free(buf); continue; @@ -355,17 +349,17 @@ int pvscan(struct cmd_context *cmd, int argc, char **argv) } if (!pvs_found) { - log_print("No matching physical volumes found"); + log_print_unless_silent("No matching physical volumes found"); unlock_vg(cmd, VG_GLOBAL); return ECMD_PROCESSED; } - log_print("Total: %d [%s] / in use: %d [%s] / in no VG: %d [%s]", - pvs_found, - display_size(cmd, size_total), - pvs_found - new_pvs_found, - display_size(cmd, (size_total - size_new)), - new_pvs_found, display_size(cmd, size_new)); + log_print_unless_silent("Total: %d [%s] / in use: %d [%s] / in no VG: %d [%s]", + pvs_found, + display_size(cmd, size_total), + pvs_found - new_pvs_found, + display_size(cmd, (size_total - size_new)), + new_pvs_found, display_size(cmd, size_new)); unlock_vg(cmd, VG_GLOBAL); |