log_print continues to print to stdout.
Version 1.02.21 -
================================
Fix dmsetup -o devno string termination. (1.02.20)
+ Print warnings to stderr instead of stdout.
Version 1.02.20 - 15th June 2007
================================
#include "libdevmapper.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
#define log_error(x...) plog(_LOG_ERR, x)
#define log_print(x...) plog(_LOG_WARN, x)
+#define log_warn(x...) plog(_LOG_WARN | _LOG_STDERR, x)
#define log_verbose(x...) plog(_LOG_NOTICE, x)
#define log_very_verbose(x...) plog(_LOG_INFO, x)
#define log_debug(x...) plog(_LOG_DEBUG, x)
struct stat buf;
char path[PATH_MAX];
- log_print("Warning: Device list may be incomplete with interface "
+ log_warn("WARNING: Device list may be incomplete with interface "
"version 1.");
- log_print("Please upgrade your kernel device-mapper driver.");
+ log_warn("Please upgrade your kernel device-mapper driver.");
if (!(d = opendir(dev_dir))) {
log_error("%s: opendir failed: %s", dev_dir, strerror(errno));
if (dmi->flags & DM_BUFFER_FULL_FLAG)
/* FIXME Increase buffer size and retry operation (if query) */
- log_error("Warning: libdevmapper buffer too small for data");
+ log_error("WARNING: libdevmapper buffer too small for data");
switch (dmt->type) {
case DM_DEVICE_CREATE:
dm_free(dmi);
goto repeat_ioctl;
default:
- log_error("Warning: libdevmapper buffer too small for data");
+ log_error("WARNING: libdevmapper buffer too small for data");
}
}
int line __attribute((unused)), const char *f, ...)
{
va_list ap;
+ int use_stderr = level & _LOG_STDERR;
+
+ level &= ~_LOG_STDERR;
if (level > _LOG_WARN && !_verbose)
return;
if (level < _LOG_WARN)
vfprintf(stderr, f, ap);
else
- vprintf(f, ap);
+ vfprintf(use_stderr ? stderr : stdout, f, ap);
va_end(ap);
if (level < _LOG_WARN)
fprintf(stderr, "\n");
else
- fprintf(stdout, "\n");
+ fprintf(use_stderr ? stderr : stdout, "\n");
}
dm_log_fn dm_log = _default_log;