mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-02 01:18:26 +03:00
Add log_errno to set a specific errno and replace log_error in due course.
This commit is contained in:
parent
d917192f00
commit
9fac443591
@ -1,5 +1,6 @@
|
|||||||
Version 2.02.50 -
|
Version 2.02.50 -
|
||||||
================================
|
================================
|
||||||
|
Add log_errno to set a specific errno and replace log_error in due course.
|
||||||
Add lvm_errno and lvm_errmsg to liblvm to obtain failure information.
|
Add lvm_errno and lvm_errmsg to liblvm to obtain failure information.
|
||||||
Change create_toolcontext to still return an object if it fails part-way.
|
Change create_toolcontext to still return an object if it fails part-way.
|
||||||
Add EUNCLASSIFIED (-1) as the default LVM errno code.
|
Add EUNCLASSIFIED (-1) as the default LVM errno code.
|
||||||
|
@ -16,6 +16,8 @@
|
|||||||
#ifndef _LVM_LOG_H
|
#ifndef _LVM_LOG_H
|
||||||
#define _LVM_LOG_H
|
#define _LVM_LOG_H
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* printf()-style macros to use for messages:
|
* printf()-style macros to use for messages:
|
||||||
*
|
*
|
||||||
@ -62,6 +64,7 @@
|
|||||||
#define log_verbose(args...) log_notice(args)
|
#define log_verbose(args...) log_notice(args)
|
||||||
#define log_print(args...) LOG_LINE(_LOG_WARN, args)
|
#define log_print(args...) LOG_LINE(_LOG_WARN, args)
|
||||||
#define log_error(args...) log_err(args)
|
#define log_error(args...) log_err(args)
|
||||||
|
#define log_errno(args...) LOG_LINE_WITH_ERRNO(_LOG_ERR, args)
|
||||||
|
|
||||||
/* System call equivalents */
|
/* System call equivalents */
|
||||||
#define log_sys_error(x, y) \
|
#define log_sys_error(x, y) \
|
||||||
|
@ -16,12 +16,17 @@
|
|||||||
#ifndef _LVM_LOGGING_H
|
#ifndef _LVM_LOGGING_H
|
||||||
#define _LVM_LOGGING_H
|
#define _LVM_LOGGING_H
|
||||||
|
|
||||||
|
#define EUNCLASSIFIED -1 /* Generic error code */
|
||||||
|
|
||||||
void print_log(int level, const char *file, int line, int dm_errno,
|
void print_log(int level, const char *file, int line, int dm_errno,
|
||||||
const char *format, ...)
|
const char *format, ...)
|
||||||
__attribute__ ((format(printf, 5, 6)));
|
__attribute__ ((format(printf, 5, 6)));
|
||||||
|
|
||||||
#define EUNCLASSIFIED -1 /* Generic error code */
|
#define LOG_LINE(l, x...) \
|
||||||
#define LOG_LINE(l, x...) print_log(l, __FILE__, __LINE__ , EUNCLASSIFIED, ## x)
|
print_log(l, __FILE__, __LINE__ , EUNCLASSIFIED, ## x)
|
||||||
|
|
||||||
|
#define LOG_LINE_WITH_ERRNO(l, e, x...) \
|
||||||
|
print_log(l, __FILE__, __LINE__ , e, ## x)
|
||||||
|
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
|
@ -21,15 +21,16 @@
|
|||||||
extern dm_log_fn dm_log;
|
extern dm_log_fn dm_log;
|
||||||
extern dm_log_with_errno_fn dm_log_with_errno;
|
extern dm_log_with_errno_fn dm_log_with_errno;
|
||||||
|
|
||||||
#define LOG_MESG(l, f, ln, x...) \
|
#define LOG_MESG(l, f, ln, e, x...) \
|
||||||
do { \
|
do { \
|
||||||
if (dm_log_is_non_default()) \
|
if (dm_log_is_non_default()) \
|
||||||
dm_log(l, f, ln, ## x); \
|
dm_log(l, f, ln, ## x); \
|
||||||
else \
|
else \
|
||||||
dm_log_with_errno(l, f, ln, 0, ## x); \
|
dm_log_with_errno(l, f, ln, e, ## x); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define LOG_LINE(l, x...) LOG_MESG(l, __FILE__, __LINE__, ## x)
|
#define LOG_LINE(l, x...) LOG_MESG(l, __FILE__, __LINE__, 0, ## x)
|
||||||
|
#define LOG_LINE_WITH_ERRNO(l, e, x...) LOG_MESG(l, __FILE__, __LINE__, e, ## x)
|
||||||
|
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
|
@ -205,7 +205,7 @@ int dm_dump_memory_debug(void)
|
|||||||
}
|
}
|
||||||
str[sizeof(str) - 1] = '\0';
|
str[sizeof(str) - 1] = '\0';
|
||||||
|
|
||||||
LOG_MESG(_LOG_INFO, mb->file, mb->line,
|
LOG_MESG(_LOG_INFO, mb->file, mb->line, 0,
|
||||||
"block %d at %p, size %" PRIsize_t "\t [%s]",
|
"block %d at %p, size %" PRIsize_t "\t [%s]",
|
||||||
mb->id, mb->magic, mb->length, str);
|
mb->id, mb->magic, mb->length, str);
|
||||||
tot += mb->length;
|
tot += mb->length;
|
||||||
|
Loading…
Reference in New Issue
Block a user