summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetr Rockai <prockai@redhat.com>2007-06-28 17:33:44 +0000
committerPetr Rockai <prockai@redhat.com>2007-06-28 17:33:44 +0000
commite7ddf4168d2c0283efe4764e89901bdca8838f93 (patch)
treea0bdb23ff8aa689dd9df96ead8a35174c6a0211d
parentba117ad80e1b8f0aafa80601b3f6970405b772e6 (diff)
downloadlvm2-e7ddf4168d2c0283efe4764e89901bdca8838f93.tar.gz
Make warnings go to stderr. Change log_warn to that effect, log_print
continues to send messages to stdout.
-rw-r--r--WHATS_NEW1
-rw-r--r--lib/activate/activate.c2
-rw-r--r--lib/commands/toolcontext.c2
-rw-r--r--lib/format_text/archiver.c2
-rw-r--r--lib/format_text/format-text.c4
-rw-r--r--lib/locking/locking.c6
-rw-r--r--lib/log/log.c9
-rw-r--r--lib/log/log.h6
-rw-r--r--lib/metadata/metadata.c14
-rw-r--r--lib/metadata/mirror.c8
-rw-r--r--scripts/lvm2_monitoring_init_rhel44
-rw-r--r--tools/lvconvert.c2
-rw-r--r--tools/lvcreate.c2
-rw-r--r--tools/lvmcmdline.c2
-rw-r--r--tools/lvmdiskscan.c2
-rw-r--r--tools/lvresize.c14
-rw-r--r--tools/pvcreate.c2
-rw-r--r--tools/pvremove.c2
-rw-r--r--tools/pvresize.c2
-rw-r--r--tools/pvscan.c2
-rw-r--r--tools/vgcfgbackup.c2
-rw-r--r--tools/vgcreate.c8
22 files changed, 52 insertions, 46 deletions
diff --git a/WHATS_NEW b/WHATS_NEW
index 25b5f2f16..a1bdd4f99 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -6,6 +6,7 @@ Version 2.02.27 -
Add --ignoremonitoring to disable all dmeventd interaction.
Remove get_ prefix from get_pv_* functions.
clvmd-openais now uses cpg_local_get() to get nodeid, rather than Clm.
+ Print warnings to stderr instead of stdout.
Version 2.02.26 - 15th June 2007
================================
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index a78c6a105..aba7f91c7 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -245,7 +245,7 @@ void set_activation(int act)
log_verbose("Activation enabled. Device-mapper kernel "
"driver will be used.");
else
- log_print("WARNING: Activation disabled. No device-mapper "
+ log_warn("WARNING: Activation disabled. No device-mapper "
"interaction will be attempted.");
}
diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c
index 13bbdc037..e3c1f9449 100644
--- a/lib/commands/toolcontext.c
+++ b/lib/commands/toolcontext.c
@@ -184,7 +184,7 @@ static int _process_config(struct cmd_context *cmd)
}
if (*cmd->proc_dir && !dir_exists(cmd->proc_dir)) {
- log_error("Warning: proc dir %s not found - some checks will be bypassed",
+ log_error("WARNING: proc dir %s not found - some checks will be bypassed",
cmd->proc_dir);
cmd->proc_dir[0] = '\0';
}
diff --git a/lib/format_text/archiver.c b/lib/format_text/archiver.c
index f3aac657b..5fa3128ec 100644
--- a/lib/format_text/archiver.c
+++ b/lib/format_text/archiver.c
@@ -214,7 +214,7 @@ static int __backup(struct volume_group *vg)
int backup(struct volume_group *vg)
{
if (!vg->cmd->backup_params->enabled || !vg->cmd->backup_params->dir) {
- log_print("WARNING: This metadata update is NOT backed up");
+ log_warn("WARNING: This metadata update is NOT backed up");
return 1;
}
diff --git a/lib/format_text/format-text.c b/lib/format_text/format-text.c
index f2f06f6c2..b43d0c83f 100644
--- a/lib/format_text/format-text.c
+++ b/lib/format_text/format-text.c
@@ -1204,8 +1204,8 @@ static int _mda_setup(const struct format_type *fmt,
/* Ensure it's not going to be bigger than the disk! */
if (start1 + mda_size1 > disk_size) {
- log_print("Warning: metadata area fills disk leaving no "
- "space for data on %s.", dev_name(pv->dev));
+ log_warn("WARNING: metadata area fills disk leaving no "
+ "space for data on %s.", dev_name(pv->dev));
/* Leave some free space for rounding */
/* Avoid empty data area as could cause tools problems */
mda_size1 = disk_size - start1 - alignment * 2;
diff --git a/lib/locking/locking.c b/lib/locking/locking.c
index 81cb992ca..6404df7ed 100644
--- a/lib/locking/locking.c
+++ b/lib/locking/locking.c
@@ -214,7 +214,7 @@ int init_locking(int type, struct cmd_context *cmd)
switch (type) {
case 0:
init_no_locking(&_locking, cmd);
- log_print("WARNING: Locking disabled. Be careful! "
+ log_warn("WARNING: Locking disabled. Be careful! "
"This could corrupt your metadata.");
return 1;
@@ -255,8 +255,8 @@ int init_locking(int type, struct cmd_context *cmd)
if ((type == 2 || type == 3) &&
find_config_tree_int(cmd, "locking/fallback_to_local_locking",
DEFAULT_FALLBACK_TO_LOCAL_LOCKING)) {
- log_print("WARNING: Falling back to local file-based locking.");
- log_print("Volume Groups with the clustered attribute will "
+ log_warn("WARNING: Falling back to local file-based locking.");
+ log_warn("Volume Groups with the clustered attribute will "
"be inaccessible.");
if (init_file_locking(&_locking, cmd))
return 1;
diff --git a/lib/log/log.c b/lib/log/log.c
index 2e657959e..a67abe675 100644
--- a/lib/log/log.c
+++ b/lib/log/log.c
@@ -302,6 +302,9 @@ void print_log(int level, const char *file, int line, const char *format, ...)
int bufused, n;
const char *message;
const char *trformat; /* Translated format string */
+ int use_stderr = level & _LOG_STDERR;
+
+ level &= ~_LOG_STDERR;
if (_log_suppress == 2)
return;
@@ -373,9 +376,9 @@ void print_log(int level, const char *file, int line, const char *format, ...)
break;
case _LOG_WARN:
if (_verbose_level >= _LOG_WARN) {
- printf("%s%s", _cmd_name, _msg_prefix);
- vprintf(trformat, ap);
- putchar('\n');
+ fprintf(use_stderr ? stderr : stdout, "%s%s", _cmd_name, _msg_prefix);
+ vfprintf(use_stderr ? stderr : stdout, trformat, ap);
+ fputc('\n', use_stderr ? stderr : stdout);
}
break;
case _LOG_ERR:
diff --git a/lib/log/log.h b/lib/log/log.h
index 925d0f996..2915d1365 100644
--- a/lib/log/log.h
+++ b/lib/log/log.h
@@ -41,6 +41,8 @@
#include <string.h> /* strerror() */
#include <errno.h>
+#define _LOG_STDERR 128 /* force things to go to stderr, even if loglevel
+ would make them go to stdout */
#define _LOG_DEBUG 7
#define _LOG_INFO 6
#define _LOG_NOTICE 5
@@ -116,14 +118,14 @@ void print_log(int level, const char *file, int line, const char *format, ...)
#define log_debug(x...) plog(_LOG_DEBUG, x)
#define log_info(x...) plog(_LOG_INFO, x)
#define log_notice(x...) plog(_LOG_NOTICE, x)
-#define log_warn(x...) plog(_LOG_WARN, x)
+#define log_warn(x...) plog(_LOG_WARN | _LOG_STDERR, x)
#define log_err(x...) plog(_LOG_ERR, x)
#define log_fatal(x...) plog(_LOG_FATAL, x)
#define stack log_debug("<backtrace>") /* Backtrace on error */
#define log_error(args...) log_err(args)
-#define log_print(args...) log_warn(args)
+#define log_print(args...) plog(_LOG_WARN, args)
#define log_verbose(args...) log_notice(args)
#define log_very_verbose(args...) log_info(args)
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 665563803..8af4e871c 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -207,8 +207,8 @@ int get_pv_from_vg_by_id(const struct format_type *fmt, const char *vg_name,
}
if (!consistent)
- log_error("Warning: Volume group %s is not consistent",
- vg_name);
+ log_warn("WARNING: Volume group %s is not consistent",
+ vg_name);
list_iterate_items(pvl, &vg->pvs) {
if (id_equal(&pvl->pv->id, (const struct id *) pvid)) {
@@ -641,7 +641,7 @@ static struct physical_volume *_pv_create(const struct format_type *fmt,
if (size) {
if (size > pv->size)
- log_print("WARNING: %s: Overriding real size. "
+ log_warn("WARNING: %s: Overriding real size. "
"You could lose data.", dev_name(pv->dev));
log_verbose("%s: Pretending size is %" PRIu64 " sectors.",
dev_name(pv->dev), size);
@@ -1324,8 +1324,8 @@ static struct volume_group *_vg_read(struct cmd_context *cmd,
return correct_vg;
}
- log_print("Inconsistent metadata found for VG %s - updating "
- "to use version %u", vgname, correct_vg->seqno);
+ log_warn("WARNING: Inconsistent metadata found for VG %s - updating "
+ "to use version %u", vgname, correct_vg->seqno);
if (!vg_write(correct_vg)) {
log_error("Automatic metadata correction failed");
@@ -1620,8 +1620,8 @@ struct list *get_pvs(struct cmd_context *cmd)
continue;
}
if (!consistent)
- log_print("Warning: Volume Group %s is not consistent",
- vgname);
+ log_warn("WARNING: Volume Group %s is not consistent",
+ vgname);
/* Move PVs onto results list */
list_iterate_safe(pvh, tmp, &vg->pvs) {
diff --git a/lib/metadata/mirror.c b/lib/metadata/mirror.c
index 78c9d1795..741e87a2f 100644
--- a/lib/metadata/mirror.c
+++ b/lib/metadata/mirror.c
@@ -377,7 +377,7 @@ int reconfigure_mirror_images(struct lv_segment *mirrored_seg, uint32_t num_mirr
/* Unable to remove bad devices */
return 0;
- log_print("WARNING: Bad device removed from mirror volume, %s/%s",
+ log_warn("WARNING: Bad device removed from mirror volume, %s/%s",
mirrored_seg->lv->vg->name, mirrored_seg->lv->name);
log_policy = get_mirror_log_fault_policy(mirrored_seg->lv->vg->cmd);
@@ -394,15 +394,15 @@ int reconfigure_mirror_images(struct lv_segment *mirrored_seg, uint32_t num_mirr
mirrored_seg->lv->vg->name, mirrored_seg->lv->name);
else if (r > 0)
/* Success in replacing device(s) */
- log_print("WARNING: Mirror volume, %s/%s restored - substitute for failed device found.",
+ log_warn("WARNING: Mirror volume, %s/%s restored - substitute for failed device found.",
mirrored_seg->lv->vg->name, mirrored_seg->lv->name);
else
/* Bad device removed, but not replaced because of policy */
if (mirrored_seg->area_count == 1) {
- log_print("WARNING: Mirror volume, %s/%s converted to linear due to device failure.",
+ log_warn("WARNING: Mirror volume, %s/%s converted to linear due to device failure.",
mirrored_seg->lv->vg->name, mirrored_seg->lv->name);
} else if (had_log && !mirrored_seg->log_lv) {
- log_print("WARNING: Mirror volume, %s/%s disk log removed due to device failure.",
+ log_warn("WARNING: Mirror volume, %s/%s disk log removed due to device failure.",
mirrored_seg->lv->vg->name, mirrored_seg->lv->name);
}
/*
diff --git a/scripts/lvm2_monitoring_init_rhel4 b/scripts/lvm2_monitoring_init_rhel4
index c9649569f..0a42f552b 100644
--- a/scripts/lvm2_monitoring_init_rhel4
+++ b/scripts/lvm2_monitoring_init_rhel4
@@ -31,7 +31,7 @@ start()
{
ret=0
# TODO do we want to separate out already active groups only?
- VGS=`vgs --noheadings -o name`
+ VGS=`vgs --noheadings -o name 2> /dev/null`
for vg in $VGS
do
action "Starting monitoring for VG $vg:" $VGCHANGE --monitor y $vg || ret=$?
@@ -49,7 +49,7 @@ stop()
echo "Not stopping monitoring, this is a dangerous operation. Please use force-stop to override."
return 1
fi
- VGS=`vgs --noheadings -o name`
+ VGS=`vgs --noheadings -o name 2> /dev/null`
for vg in $VGS
do
action "Stopping monitoring for VG $vg:" $VGCHANGE --monitor n $vg || ret=$?
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index ccc8b1761..aeb01c6ea 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -447,7 +447,7 @@ static int lvconvert_snapshot(struct cmd_context *cmd,
}
if (!lp->zero || !(lv->status & LVM_WRITE))
- log_print("WARNING: \"%s\" not zeroed", lv->name);
+ log_warn("WARNING: \"%s\" not zeroed", lv->name);
else if (!set_lv(cmd, lv, 0, 0)) {
log_error("Aborting. Failed to wipe snapshot "
"exception store.");
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index ec3af687e..4da683fa1 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -693,7 +693,7 @@ static int _lvcreate(struct cmd_context *cmd, struct lvcreate_params *lp)
init_mirror_in_sync(lp->nosync);
if (lp->nosync) {
- log_print("WARNING: New mirror won't be synchronised. "
+ log_warn("WARNING: New mirror won't be synchronised. "
"Don't read what you didn't write!");
status |= MIRROR_NOTSYNCED;
}
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index 6c0ccfd9b..039eb519f 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -733,7 +733,7 @@ static int _get_settings(struct cmd_context *cmd)
return EINVALID_CMD_LINE;
}
init_trust_cache(1);
- log_print("WARNING: Cache file of PVs will be trusted. "
+ log_warn("WARNING: Cache file of PVs will be trusted. "
"New devices holding PVs may get ignored.");
} else
init_trust_cache(0);
diff --git a/tools/lvmdiskscan.c b/tools/lvmdiskscan.c
index 0d8ab0461..a64925e73 100644
--- a/tools/lvmdiskscan.c
+++ b/tools/lvmdiskscan.c
@@ -106,7 +106,7 @@ int lvmdiskscan(struct cmd_context *cmd, int argc __attribute((unused)),
pv_parts_found = 0;
if (arg_count(cmd, lvmpartition_ARG))
- log_print("WARNING: only considering LVM devices");
+ log_warn("WARNING: only considering LVM devices");
max_len = _get_max_dev_name_len(cmd->filter);
diff --git a/tools/lvresize.c b/tools/lvresize.c
index c9fee4381..46d7a3b9a 100644
--- a/tools/lvresize.c
+++ b/tools/lvresize.c
@@ -155,14 +155,14 @@ static int _lvresize(struct cmd_context *cmd, struct lvresize_params *lp)
if (vg->fid->fmt->features & FMT_SEGMENTS)
lp->stripes = arg_uint_value(cmd, stripes_ARG, 1);
else
- log_print("Varied striping not supported. Ignoring.");
+ log_warn("Varied striping not supported. Ignoring.");
}
if (arg_count(cmd, mirrors_ARG)) {
if (vg->fid->fmt->features & FMT_SEGMENTS)
lp->mirrors = arg_uint_value(cmd, mirrors_ARG, 1) + 1;
else
- log_print("Mirrors not supported. Ignoring.");
+ log_warn("Mirrors not supported. Ignoring.");
if (arg_sign_value(cmd, mirrors_ARG, 0) == SIGN_MINUS) {
log_error("Mirrors argument may not be negative");
return 0;
@@ -182,7 +182,7 @@ static int _lvresize(struct cmd_context *cmd, struct lvresize_params *lp)
}
if (!(vg->fid->fmt->features & FMT_SEGMENTS))
- log_print("Varied stripesize not supported. Ignoring.");
+ log_warn("Varied stripesize not supported. Ignoring.");
else if (arg_uint_value(cmd, stripesize_ARG, 0) > vg->extent_size) {
log_error("Reducing stripe size %s to maximum, "
"physical extent size %s",
@@ -447,7 +447,7 @@ static int _lvresize(struct cmd_context *cmd, struct lvresize_params *lp)
if (lp->resize == LV_REDUCE) {
if (lp->argc)
- log_print("Ignoring PVs on command line when reducing");
+ log_warn("Ignoring PVs on command line when reducing");
} else if (!(pvh = lp->argc ? create_pv_list(cmd->mem, vg, lp->argc,
lp->argv, 1) : &vg->pvs)) {
stack;
@@ -469,13 +469,13 @@ static int _lvresize(struct cmd_context *cmd, struct lvresize_params *lp)
}
if (info.exists && !lp->resizefs && (lp->resize == LV_REDUCE)) {
- log_print("WARNING: Reducing active%s logical volume "
+ log_warn("WARNING: Reducing active%s logical volume "
"to %s", info.open_count ? " and open" : "",
display_size(cmd, (uint64_t) lp->extents *
vg->extent_size));
- log_print("THIS MAY DESTROY YOUR DATA "
- "(filesystem etc.)");
+ log_warn("THIS MAY DESTROY YOUR DATA "
+ "(filesystem etc.)");
if (!arg_count(cmd, force_ARG)) {
if (yes_no_prompt("Do you really want to "
diff --git a/tools/pvcreate.c b/tools/pvcreate.c
index 34c263087..457bc0a90 100644
--- a/tools/pvcreate.c
+++ b/tools/pvcreate.c
@@ -110,7 +110,7 @@ static int pvcreate_check(struct cmd_context *cmd, const char *name)
return 0;
if (pv && !is_orphan(pv) && arg_count(cmd, force_ARG)) {
- log_print("WARNING: Forcing physical volume creation on "
+ log_warn("WARNING: Forcing physical volume creation on "
"%s%s%s%s", name,
!is_orphan(pv) ? " of volume group \"" : "",
!is_orphan(pv) ? pv_vg_name(pv) : "",
diff --git a/tools/pvremove.c b/tools/pvremove.c
index 8567e006a..0e6009419 100644
--- a/tools/pvremove.c
+++ b/tools/pvremove.c
@@ -62,7 +62,7 @@ static int pvremove_check(struct cmd_context *cmd, const char *name)
}
if (arg_count(cmd, force_ARG)) {
- log_print("WARNING: Wiping physical volume label from "
+ log_warn("WARNING: Wiping physical volume label from "
"%s%s%s%s", name,
!is_orphan(pv) ? " of volume group \"" : "",
!is_orphan(pv) ? pv_vg_name(pv) : "",
diff --git a/tools/pvresize.c b/tools/pvresize.c
index 3c49082b3..ed1516987 100644
--- a/tools/pvresize.c
+++ b/tools/pvresize.c
@@ -111,7 +111,7 @@ static int _pvresize_single(struct cmd_context *cmd,
if (params->new_size) {
if (params->new_size > size)
- log_print("WARNING: %s: Overriding real size. "
+ log_warn("WARNING: %s: Overriding real size. "
"You could lose data.", pv_name);
log_verbose("%s: Pretending size is %" PRIu64 " not %" PRIu64
" sectors.", pv_name, params->new_size, pv_size(pv));
diff --git a/tools/pvscan.c b/tools/pvscan.c
index 6f3a90920..6d86db263 100644
--- a/tools/pvscan.c
+++ b/tools/pvscan.c
@@ -120,7 +120,7 @@ int pvscan(struct cmd_context *cmd, int argc __attribute((unused)),
}
if (arg_count(cmd, exported_ARG) || arg_count(cmd, novolumegroup_ARG))
- log_print("WARNING: only considering physical volumes %s",
+ log_warn("WARNING: only considering physical volumes %s",
arg_count(cmd, exported_ARG) ?
"of exported volume group(s)" : "in no volume group");
diff --git a/tools/vgcfgbackup.c b/tools/vgcfgbackup.c
index b1af733ca..acc6f9e96 100644
--- a/tools/vgcfgbackup.c
+++ b/tools/vgcfgbackup.c
@@ -61,7 +61,7 @@ static int vg_backup_single(struct cmd_context *cmd, const char *vg_name,
}
if (!consistent)
- log_error("Warning: Volume group \"%s\" inconsistent", vg_name);
+ log_error("WARNING: Volume group \"%s\" inconsistent", vg_name);
if (arg_count(cmd, file_ARG)) {
if (!(filename = _expand_filename(arg_value(cmd, file_ARG),
diff --git a/tools/vgcreate.c b/tools/vgcreate.c
index 5ae6f9c2e..7ad22882a 100644
--- a/tools/vgcreate.c
+++ b/tools/vgcreate.c
@@ -95,12 +95,12 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv)
return ECMD_FAILED;
if (max_lv != vg->max_lv)
- log_error("Warning: Setting maxlogicalvolumes to %d "
- "(0 means unlimited)", vg->max_lv);
+ log_warn("WARNING: Setting maxlogicalvolumes to %d "
+ "(0 means unlimited)", vg->max_lv);
if (max_pv != vg->max_pv)
- log_error("Warning: Setting maxphysicalvolumes to %d "
- "(0 means unlimited)", vg->max_pv);
+ log_warn("WARNING: Setting maxphysicalvolumes to %d "
+ "(0 means unlimited)", vg->max_pv);
if (arg_count(cmd, addtag_ARG)) {
if (!(tag = arg_str_value(cmd, addtag_ARG, NULL))) {