]> sourceware.org Git - lvm2.git/commitdiff
Make warnings go to stderr. Change log_warn to that effect, log_print
authorPetr Rockai <prockai@redhat.com>
Thu, 28 Jun 2007 17:33:44 +0000 (17:33 +0000)
committerPetr Rockai <prockai@redhat.com>
Thu, 28 Jun 2007 17:33:44 +0000 (17:33 +0000)
continues to send messages to stdout.

22 files changed:
WHATS_NEW
lib/activate/activate.c
lib/commands/toolcontext.c
lib/format_text/archiver.c
lib/format_text/format-text.c
lib/locking/locking.c
lib/log/log.c
lib/log/log.h
lib/metadata/metadata.c
lib/metadata/mirror.c
scripts/lvm2_monitoring_init_rhel4
tools/lvconvert.c
tools/lvcreate.c
tools/lvmcmdline.c
tools/lvmdiskscan.c
tools/lvresize.c
tools/pvcreate.c
tools/pvremove.c
tools/pvresize.c
tools/pvscan.c
tools/vgcfgbackup.c
tools/vgcreate.c

index 25b5f2f16f1e4f86197b5c84d329e279c4e90a71..a1bdd4f99693f7b78390fe0c607a44eeb254bece 100644 (file)
--- 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
 ================================
index a78c6a1053a25e9c2961e64cceafc8dceaaa9042..aba7f91c702f6bc6d4f20e752e8cecf7abc8a55b 100644 (file)
@@ -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.");
 }
 
index 13bbdc037b9ca0791e50f0ef269cab71b7e5ea8c..e3c1f9449824c90afbccf4d1346109621e202f63 100644 (file)
@@ -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';
        }
index f3aac657bc2618759ede82692daab5be5b316af1..5fa3128ece0cc041a37e90df730e7f42b8809d87 100644 (file)
@@ -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;
        }
 
index f2f06f6c22f1726bac5ed523e6c4721a4c9e5926..b43d0c83f2766454e6025b4458503a3eba094565 100644 (file)
@@ -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;
index 81cb992ca03833e86304b34c331ea65690302f22..6404df7edeb85a1214b1d645483ee78f7b86bee5 100644 (file)
@@ -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;
index 2e657959e773349a5ac6d11e84aefc486c1dba62..a67abe675d57a5062c2ec36b81ea8b1e5ec89450 100644 (file)
@@ -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:
index 925d0f996770d1a4ac58af6200367cea3227a17b..2915d1365dc9d7a3150acc8db261bed4527f3faa 100644 (file)
@@ -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)
 
index 665563803d8d830e254ff24729e166216b8b77e0..8af4e871cbcc06b3e4fc5a3c98f9b93834d37b38 100644 (file)
@@ -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) {
index 78c9d1795b59515fbd938ce37a7f164a751faf79..741e87a2f6159bb9fa756798907100372422b0d7 100644 (file)
@@ -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);
                }
        /*
index c9649569f6f4b01fcae15e702a102dc12d3df5fa..0a42f552bebc54a00fd4b24eb48ccd69526611d4 100644 (file)
@@ -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=$?
index ccc8b1761d5f3d35e86c7ecf6e0cddcb55f38f05..aeb01c6ea925c324ebcfff8a262741e4728a06c8 100644 (file)
@@ -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.");
index ec3af687e4883161ae57fdbf2a18a196ecd911ed..4da683fa1e9d6a063597ef22a89c6e3d199b1bfd 100644 (file)
@@ -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;
                }
index 6c0ccfd9b7c0f66ed2400ac5bec2a39e51ead080..039eb519f25db8b7757ca52309b10badaf555a08 100644 (file)
@@ -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);
index 0d8ab0461a123b2b05fa81c800acad2ad5a66ce7..a64925e731b3eba5b3a79e45da8111cb0cd0c623 100644 (file)
@@ -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);
 
index c9fee4381a3ac0d948b5a83d8cbd9a22d7d81274..46d7a3b9aee2cfb1f323a3c4b4c0b77045c8fb9c 100644 (file)
@@ -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 "
index 34c2630876420c4d61af7bf67ee8ab292d27f9e8..457bc0a908fc4bd73f26cb0428d77b72a6e64b60 100644 (file)
@@ -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) : "",
index 8567e006a2d35536a3f1171699204f2cb5db312d..0e6009419cc6ff506ae8f121d5d58b4c066c96f0 100644 (file)
@@ -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) : "",
index 3c49082b3eaf53eec8c28c58be9ba945e8c2987a..ed1516987a3ba152dac834ac316c412326d804e6 100644 (file)
@@ -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));
index 6f3a909205674aeaf06a7c5c94eb9185619b63f7..6d86db2633c83dc55fce59e6f1c9a29fe3d37031 100644 (file)
@@ -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");
 
index b1af733ca60ba3db3cc7404e47810612edce4092..acc6f9e960adc31d4fe048540bd9168b680bfde2 100644 (file)
@@ -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),
index 5ae6f9c2e95da35e7b416e8209f6718518793659..7ad22882a1586fb45395086aa2b387b53cdf9360 100644 (file)
@@ -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))) {
This page took 0.066497 seconds and 5 git commands to generate.