1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-03 05:18:29 +03:00

Fix output if overriding command_names on cmdline.

This commit is contained in:
Milan Broz 2008-04-07 13:53:26 +00:00
parent 5619c629f6
commit 8bf70e11ee
2 changed files with 18 additions and 10 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.34 - Version 2.02.34 -
=================================== ===================================
Fix output if overriding command_names on cmdline.
Add detection of clustered mirror log capability. Add detection of clustered mirror log capability.
Add check to vg_commit() ensuring VG lock held before writing new VG metadata. Add check to vg_commit() ensuring VG lock held before writing new VG metadata.
Add validation of LV name to pvmove -n. Add validation of LV name to pvmove -n.

View File

@ -215,12 +215,18 @@ void init_cmd_name(int status)
void set_cmd_name(const char *cmd) void set_cmd_name(const char *cmd)
{ {
if (!_log_cmd_name)
return;
strncpy(_cmd_name, cmd, sizeof(_cmd_name)); strncpy(_cmd_name, cmd, sizeof(_cmd_name));
_cmd_name[sizeof(_cmd_name) - 1] = '\0'; _cmd_name[sizeof(_cmd_name) - 1] = '\0';
} }
static const char *_command_name()
{
if (!_log_cmd_name)
return "";
return _cmd_name;
}
void init_msg_prefix(const char *prefix) void init_msg_prefix(const char *prefix)
{ {
strncpy(_msg_prefix, prefix, sizeof(_msg_prefix)); strncpy(_msg_prefix, prefix, sizeof(_msg_prefix));
@ -352,7 +358,7 @@ void print_log(int level, const char *file, int line, const char *format, ...)
_verbose_level <= _LOG_DEBUG) _verbose_level <= _LOG_DEBUG)
break; break;
if (_verbose_level >= _LOG_DEBUG) { if (_verbose_level >= _LOG_DEBUG) {
fprintf(stderr, "%s%s%s", locn, _cmd_name, fprintf(stderr, "%s%s%s", locn, _command_name(),
_msg_prefix); _msg_prefix);
if (_indent) if (_indent)
fprintf(stderr, " "); fprintf(stderr, " ");
@ -363,7 +369,7 @@ void print_log(int level, const char *file, int line, const char *format, ...)
case _LOG_INFO: case _LOG_INFO:
if (_verbose_level >= _LOG_INFO) { if (_verbose_level >= _LOG_INFO) {
fprintf(stderr, "%s%s%s", locn, _cmd_name, fprintf(stderr, "%s%s%s", locn, _command_name(),
_msg_prefix); _msg_prefix);
if (_indent) if (_indent)
fprintf(stderr, " "); fprintf(stderr, " ");
@ -373,7 +379,7 @@ void print_log(int level, const char *file, int line, const char *format, ...)
break; break;
case _LOG_NOTICE: case _LOG_NOTICE:
if (_verbose_level >= _LOG_NOTICE) { if (_verbose_level >= _LOG_NOTICE) {
fprintf(stderr, "%s%s%s", locn, _cmd_name, fprintf(stderr, "%s%s%s", locn, _command_name(),
_msg_prefix); _msg_prefix);
if (_indent) if (_indent)
fprintf(stderr, " "); fprintf(stderr, " ");
@ -383,14 +389,15 @@ void print_log(int level, const char *file, int line, const char *format, ...)
break; break;
case _LOG_WARN: case _LOG_WARN:
if (_verbose_level >= _LOG_WARN) { if (_verbose_level >= _LOG_WARN) {
fprintf(use_stderr ? stderr : stdout, "%s%s", _cmd_name, _msg_prefix); fprintf(use_stderr ? stderr : stdout, "%s%s",
_command_name(), _msg_prefix);
vfprintf(use_stderr ? stderr : stdout, trformat, ap); vfprintf(use_stderr ? stderr : stdout, trformat, ap);
fputc('\n', use_stderr ? stderr : stdout); fputc('\n', use_stderr ? stderr : stdout);
} }
break; break;
case _LOG_ERR: case _LOG_ERR:
if (_verbose_level >= _LOG_ERR) { if (_verbose_level >= _LOG_ERR) {
fprintf(stderr, "%s%s%s", locn, _cmd_name, fprintf(stderr, "%s%s%s", locn, _command_name(),
_msg_prefix); _msg_prefix);
vfprintf(stderr, trformat, ap); vfprintf(stderr, trformat, ap);
fputc('\n', stderr); fputc('\n', stderr);
@ -399,7 +406,7 @@ void print_log(int level, const char *file, int line, const char *format, ...)
case _LOG_FATAL: case _LOG_FATAL:
default: default:
if (_verbose_level >= _LOG_FATAL) { if (_verbose_level >= _LOG_FATAL) {
fprintf(stderr, "%s%s%s", locn, _cmd_name, fprintf(stderr, "%s%s%s", locn, _command_name(),
_msg_prefix); _msg_prefix);
vfprintf(stderr, trformat, ap); vfprintf(stderr, trformat, ap);
fputc('\n', stderr); fputc('\n', stderr);
@ -413,7 +420,7 @@ void print_log(int level, const char *file, int line, const char *format, ...)
return; return;
if (_log_to_file && (_log_while_suspended || !memlock())) { if (_log_to_file && (_log_while_suspended || !memlock())) {
fprintf(_log_file, "%s:%d %s%s", file, line, _cmd_name, fprintf(_log_file, "%s:%d %s%s", file, line, _command_name(),
_msg_prefix); _msg_prefix);
va_start(ap, format); va_start(ap, format);
@ -436,7 +443,7 @@ void print_log(int level, const char *file, int line, const char *format, ...)
memset(&buf, ' ', sizeof(buf)); memset(&buf, ' ', sizeof(buf));
bufused = 0; bufused = 0;
if ((n = dm_snprintf(buf, sizeof(buf) - bufused - 1, if ((n = dm_snprintf(buf, sizeof(buf) - bufused - 1,
"%s:%d %s%s", file, line, _cmd_name, "%s:%d %s%s", file, line, _command_name(),
_msg_prefix)) == -1) _msg_prefix)) == -1)
goto done; goto done;