]> sourceware.org Git - lvm2.git/commitdiff
standardise some log messages
authorAlasdair Kergon <agk@redhat.com>
Wed, 10 Oct 2001 16:36:32 +0000 (16:36 +0000)
committerAlasdair Kergon <agk@redhat.com>
Wed, 10 Oct 2001 16:36:32 +0000 (16:36 +0000)
lib/config/config.c
lib/device/dev-cache.c
lib/device/dev-io.c
lib/format1/disk-rep.c
lib/log/log.c
lib/log/log.h
tools/vgrename.c

index 0dbb4ac6f4b1ad86f4240878a26dc838f1a200f0..4c4c79fc0268edeaf29f0ba56f288ca317c77ae0 100644 (file)
@@ -115,18 +115,18 @@ int read_config(struct config_file *cf, const char *file)
 
         /* memory map the file */
         if (stat(file, &info) || S_ISDIR(info.st_mode)) {
-                log_sys_err("stat");
+                log_sys_error("stat", file);
                 return 0;
         }
 
         if ((fd = open(file, O_RDONLY)) < 0) {
-                log_sys_err("open");
+                log_sys_error("open", file);
                 return 0;
         }
 
         p->fb = mmap((caddr_t) 0, info.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
         if (p->fb == MAP_FAILED) {
-                log_sys_err("mmap");
+                log_sys_error("mmap", file);
                 close(fd);
                 return 0;
         }
@@ -143,7 +143,7 @@ int read_config(struct config_file *cf, const char *file)
 
         /* unmap the file */
         if (munmap((char *) p->fb, info.st_size)) {
-                log_sys_err("munmap failed");
+                log_sys_error("munmap", file);
                 r = 0;
         }
 
@@ -216,7 +216,7 @@ int write_config(struct config_file *cf, const char *file)
        int r = 1;
         FILE *fp = fopen(file, "w");
         if (!fp) {
-                log_sys_err("open");
+                log_sys_error("open", file);
                 return 0;
         }
 
index c63100b106958c2d555260b4a5b92e42fb1e44c7..f4ebe51a9fb63263a9cecaf0aeed4166eb6b17b2 100644 (file)
@@ -63,7 +63,7 @@ static char *_follow_link(const char *path, struct stat *info)
        buffer[n] = '\0';
 
        if (stat(buffer, info) < 0) {
-               log_sys_err("stat");
+               log_sys_very_verbose("stat", buffer);
                return NULL;
        }
 
@@ -123,10 +123,10 @@ static int _insert(const char *path, int recurse)
        struct stat info;
        struct device *dev;
 
-       log_debug("dev-cache adding %s", path);
+       log_very_verbose("dev-cache adding %s", path);
 
        if (stat(path, &info) < 0) {
-               log_sys_err("stat");
+               log_sys_very_verbose("stat", path);
                return 0;
        }
 
index 565ed6c702fea7caad7093bf36de4296f6885028..b39be193f6d8960db775bec3ecbd0454638632ff 100644 (file)
@@ -20,15 +20,15 @@ int dev_get_size(struct device *dev, uint64_t *size)
        int fd;
        long s;
 
-       log_verbose("Getting device size");
+       log_very_verbose("Getting size of %s", dev->name);
        if ((fd = open(dev->name, O_RDONLY)) < 0) {
-               log_sys_err("open");
+               log_sys_error("open", dev->name);
                return 0;
        }
 
        /* FIXME: add 64 bit ioctl */
        if (ioctl(fd, BLKGETSIZE, &s) < 0) {
-               log_sys_err("ioctl");
+               log_sys_error("ioctl BLKGETSIZE", dev->name);
                close(fd);
                return 0;
        }
@@ -67,12 +67,12 @@ int64_t dev_read(struct device *dev, uint64_t offset,
        int fd = open(dev->name, O_RDONLY);
 
        if (fd < 0) {
-               log_sys_err("open");
+               log_sys_very_verbose("open", dev->name);
                return 0;
        }
 
        if (lseek(fd, offset, SEEK_SET) < 0) {
-               log_sys_err("lseek");
+               log_sys_error("lseek", dev->name);
                return 0;
        }
 
@@ -106,12 +106,12 @@ int64_t dev_write(struct device *dev, uint64_t offset,
        int fd = open(dev->name, O_WRONLY);
 
        if (fd < 0) {
-               log_sys_err("open");
+               log_sys_error("open", dev->name);
                return 0;
        }
 
        if (lseek(fd, offset, SEEK_SET) < 0) {
-               log_sys_err("lseek");
+               log_sys_error("lseek", dev->name);
                return 0;
        }
 
index 27d9d21aaa2ab37a5b7230719337f1c397a6487e..894f71deabb05cd25264c06830434f0ba966bb9c 100644 (file)
@@ -234,13 +234,13 @@ struct disk_list *read_pv(struct device *dev, struct pool *mem,
        }
 
        if (data->pv.id[0] != 'H' || data->pv.id[1] != 'M') {
-               log_debug("%s does not have a valid PV identifier.",
+               log_very_verbose("%s does not have a valid PV identifier",
                         dev->name);
                goto bad;
        }
 
        if (!_munge_formats(&data->pv)) {
-               log_verbose("Unknown metadata version %d found on %s", 
+               log_very_verbose("Unknown metadata version %d found on %s", 
                            data->pv.version, dev->name);
                goto bad;
        }
@@ -249,8 +249,7 @@ struct disk_list *read_pv(struct device *dev, struct pool *mem,
         * is it an orphan ?
         */
        if (data->pv.vg_name == '\0') {
-               log_very_verbose("%s is not a member of any VG",
-                                dev->name);
+               log_very_verbose("%s is not a member of any VG", dev->name);
                return data;
        }
 
index cc92be5d7b14032a4da4c347770771f9f2dc2b24..70827fed67e35399ea8e891e31dc920818654714 100644 (file)
@@ -59,8 +59,8 @@ void print_log(int level, const char *file, int line, const char *format, ...) {
        va_start(ap, format);
        switch(level) {
          case _LOG_DEBUG:
-               if (_verbose_level > 2) {
-                       printf("      ");
+               if (_verbose_level > 2 && format[1]) {
+                       printf("        ");
                        vprintf(format, ap);
                        putchar('\n');
                }
index 19786cdd993e052a3eeceee51fa611c0046041df..8e16d8a19b54aa8d2b6af86701bc245b56f21377 100644 (file)
@@ -42,10 +42,8 @@ void print_log(int level, const char *file, int line, const char *format, ...)
 #define log_warn(x...) plog(_LOG_WARN, x)
 #define log_err(x...) plog(_LOG_ERR, x)
 #define log_fatal(x...) plog(_LOG_FATAL, x)
-#define log_sys_err(x)  log_debug("system call '%s' failed (%s)", \
-                                  x, strerror(errno))
 
-#define stack log_debug( "stack trace" )
+#define stack log_debug( "s" )
 
 /*
  * Macros to use for messages:
@@ -55,6 +53,7 @@ void print_log(int level, const char *file, int line, const char *format, ...)
  *   log_verbose - print to stdout if verbose is set (-v)
  *   log_very_verbose - print to stdout if verbose is set twice (-vv)
  *   log_debug - print to stdout if verbose is set three times (-vvv)
+ *               (suppressed if single-character string such as with 'stack')
  *
  * In addition, messages will be logged to file or syslog if they
  * are more serious than the log level specified with -d.
@@ -65,6 +64,12 @@ void print_log(int level, const char *file, int line, const char *format, ...)
 #define log_verbose(fmt, args...) log_notice(fmt , ## args)
 #define log_very_verbose(fmt, args...) log_info(fmt , ## args)
 
+/* System call equivalents */
+#define log_sys_error(x, y) \
+               log_err("%s: %s failed: %s", y, x, strerror(errno))
+#define log_sys_very_verbose(x, y) \
+               log_info("%s: %s failed: %s", y, x, strerror(errno))
+
 #endif
 
 /*
index 029e1033934015d2cb58aafe957be3f16e44d96d..ac202745385e8cdb853b78beab6d79b2da35738e 100644 (file)
@@ -106,7 +106,7 @@ int vgrename(int argc, char **argv)
        sprintf(new_path, "%s%s", prefix, vg_name_new);
 
        log_verbose("Renaming %s to %s", old_path, new_path);
-       if (!(rename(old_path, new_path))) {
+       if (rename(old_path, new_path)) {
                log_error("Renaming %s to %s failed: %s",
                          old_path, new_path, strerror(errno));
                return ECMD_FAILED;
This page took 0.048746 seconds and 5 git commands to generate.