1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-24 06:04:19 +03:00

Rebaseline internal verbose level.

This commit is contained in:
Alasdair Kergon 2004-03-26 11:45:01 +00:00
parent 83f788af57
commit 35cf1b3b5b
5 changed files with 24 additions and 17 deletions

View File

@ -85,7 +85,7 @@ static void _init_logging(struct cmd_context *cmd)
/* Verbose level for tty output */
cmd->default_settings.verbose =
find_config_int(cmd->cft->root, "log/verbose", DEFAULT_VERBOSE);
init_verbose(cmd->default_settings.verbose);
init_verbose(cmd->default_settings.verbose + VERBOSE_BASE_LEVEL);
/* Log message formatting */
init_indent(find_config_int(cmd->cft->root, "log/indent",

View File

@ -16,7 +16,7 @@ static FILE *_log_file;
static struct device _log_dev;
static struct str_list _log_dev_alias;
static int _verbose_level = 0;
static int _verbose_level = VERBOSE_BASE_LEVEL;
static int _test = 0;
static int _partial = 0;
static int _pvmove = 0;
@ -197,7 +197,7 @@ void print_log(int level, const char *file, int line, const char *format, ...)
case _LOG_DEBUG:
if (!strcmp("<backtrace>", format))
break;
if (_verbose_level > 2) {
if (_verbose_level >= _LOG_DEBUG) {
printf("%s%s", _cmd_name, _msg_prefix);
if (_indent)
printf(" ");
@ -207,7 +207,7 @@ void print_log(int level, const char *file, int line, const char *format, ...)
break;
case _LOG_INFO:
if (_verbose_level > 1) {
if (_verbose_level >= _LOG_INFO) {
printf("%s%s", _cmd_name, _msg_prefix);
if (_indent)
printf(" ");
@ -216,7 +216,7 @@ void print_log(int level, const char *file, int line, const char *format, ...)
}
break;
case _LOG_NOTICE:
if (_verbose_level) {
if (_verbose_level >= _LOG_NOTICE) {
printf("%s%s", _cmd_name, _msg_prefix);
if (_indent)
printf(" ");
@ -225,22 +225,27 @@ void print_log(int level, const char *file, int line, const char *format, ...)
}
break;
case _LOG_WARN:
printf("%s%s", _cmd_name, _msg_prefix);
vprintf(trformat, ap);
putchar('\n');
if (_verbose_level >= _LOG_WARN) {
printf("%s%s", _cmd_name, _msg_prefix);
vprintf(trformat, ap);
putchar('\n');
}
break;
case _LOG_ERR:
fprintf(stderr, "%s%s", _cmd_name, _msg_prefix);
vfprintf(stderr, trformat, ap);
fputc('\n', stderr);
if (_verbose_level >= _LOG_ERR) {
fprintf(stderr, "%s%s", _cmd_name, _msg_prefix);
vfprintf(stderr, trformat, ap);
fputc('\n', stderr);
}
break;
case _LOG_FATAL:
default:
fprintf(stderr, "%s%s", _cmd_name, _msg_prefix);
vfprintf(stderr, trformat, ap);
fputc('\n', stderr);
if (_verbose_level >= _LOG_FATAL) {
fprintf(stderr, "%s%s", _cmd_name, _msg_prefix);
vfprintf(stderr, trformat, ap);
fputc('\n', stderr);
}
break;
;
}
va_end(ap);
}

View File

@ -39,6 +39,8 @@
#define _LOG_ERR 3
#define _LOG_FATAL 2
#define VERBOSE_BASE_LEVEL _LOG_WARN
void init_log_file(const char *log_file, int append);
void init_log_direct(const char *log_file, int append);
void init_log_while_suspended(int log_while_suspended);

View File

@ -680,7 +680,7 @@ int help(struct cmd_context *cmd, int argc, char **argv)
static void _apply_settings(struct cmd_context *cmd)
{
init_debug(cmd->current_settings.debug);
init_verbose(cmd->current_settings.verbose);
init_verbose(cmd->current_settings.verbose + VERBOSE_BASE_LEVEL);
init_test(cmd->current_settings.test);
init_msg_prefix(cmd->default_settings.msg_prefix);

View File

@ -60,7 +60,7 @@ static int _become_daemon(struct cmd_context *cmd)
if (setsid() == -1)
log_error("Background process failed to setsid: %s",
strerror(errno));
init_verbose(0);
init_verbose(VERBOSE_BASE_LEVEL);
close(STDIN_FILENO);
close(STDOUT_FILENO);