Gitweb:
http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 5b7d0817560827d007b5ee0927a9dbb414aa1121
Parent: c0c86631cd56ee2f91295034a039685044fc11b7
Author: Bob Peterson <bob(a)ganesha.peterson>
AuthorDate: Thu Jan 21 09:07:45 2010 -0600
Committer: Bob Peterson <rpeterso(a)redhat.com>
CommitterDate: Tue Jan 26 14:39:29 2010 -0600
libgfs2: gfs2_log reform
This patch reforms the log_ functions of libgfs2 to be a bit
more efficient by getting rid of sub-structures and levels.
rhbz#455300
---
gfs2/libgfs2/gfs2_log.c | 20 ++++++--------------
gfs2/libgfs2/libgfs2.h | 40 ++++++++++++----------------------------
2 files changed, 18 insertions(+), 42 deletions(-)
diff --git a/gfs2/libgfs2/gfs2_log.c b/gfs2/libgfs2/gfs2_log.c
index 622589b..c349840 100644
--- a/gfs2/libgfs2/gfs2_log.c
+++ b/gfs2/libgfs2/gfs2_log.c
@@ -12,19 +12,16 @@
#define _(String) gettext(String)
-struct log_state {
- int print_level;
-};
-static struct log_state _state = {MSG_NOTICE};
+int print_level = MSG_NOTICE;
void increase_verbosity(void)
{
- _state.print_level++;
+ print_level++;
}
void decrease_verbosity(void)
{
- _state.print_level--;
+ print_level--;
}
static __attribute__((format (printf, 4, 0)))
@@ -34,9 +31,8 @@ void print_msg(int priority, const char *file, int line,
switch (priority) {
case MSG_DEBUG:
- printf("(%s:%d)\t", file, line);
+ printf("(%s:%d) ", file, line);
vprintf(format, args);
- fflush(NULL);
break;
case MSG_INFO:
case MSG_NOTICE:
@@ -53,7 +49,7 @@ void print_msg(int priority, const char *file, int line,
}
-void print_fsck_log(int iif, int priority, const char *file, int line,
+void print_fsck_log(int priority, const char *file, int line,
const char *format, ...)
{
va_list args;
@@ -61,11 +57,7 @@ void print_fsck_log(int iif, int priority, const char *file, int line,
va_start(args, format);
transform = _(format);
-
- if((_state.print_level == priority) ||
- (!iif && (_state.print_level >= priority)))
- print_msg(priority, file, line, transform, args);
-
+ print_msg(priority, file, line, transform, args);
va_end(args);
}
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index b0745aa..86db414 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -512,6 +512,8 @@ struct gfs2_options {
unsigned int query:1;
};
+extern int print_level;
+
#define MSG_DEBUG 7
#define MSG_INFO 6
#define MSG_NOTICE 5
@@ -520,52 +522,34 @@ struct gfs2_options {
#define MSG_CRITICAL 2
#define MSG_NULL 1
-#define print_log(iif, priority, format...) \
-do { print_fsck_log(iif, priority, __FILE__, __LINE__, ## format); } while(0)
+#define print_log(priority, format...) \
+ do { print_fsck_log(priority, __FILE__, __LINE__, ## format); } while(0)
#define log_debug(format...) \
-do { print_log(0, MSG_DEBUG, format); } while(0)
+ do { if(print_level >= MSG_DEBUG) print_log(MSG_DEBUG, format); } while(0)
#define log_info(format...) \
-do { print_log(0, MSG_INFO, format); } while(0)
+ do { if(print_level >= MSG_INFO) print_log(MSG_INFO, format); } while(0)
#define log_notice(format...) \
-do { print_log(0, MSG_NOTICE, format); } while(0)
+ do { if(print_level >= MSG_NOTICE) print_log(MSG_NOTICE, format); } while(0)
#define log_warn(format...) \
-do { print_log(0, MSG_WARN, format); } while(0)
+ do { if(print_level >= MSG_WARN) print_log(MSG_WARN, format); } while(0)
#define log_err(format...) \
-do { print_log(0, MSG_ERROR, format); } while(0)
+ do { if(print_level >= MSG_ERROR) print_log(MSG_ERROR, format); } while(0)
#define log_crit(format...) \
-do { print_log(0, MSG_CRITICAL, format); } while(0)
+ do { if(print_level >= MSG_CRITICAL) print_log(MSG_CRITICAL, format); } while(0)
#define stack log_debug("<backtrace> - %s()\n", __func__)
-#define log_at_debug(format...) \
-do { print_log(1, MSG_DEBUG, format); } while(0)
-
-#define log_at_info(format...) \
-do { print_log(1, MSG_INFO, format); } while(0)
-
-#define log_at_notice(format...) \
-do { print_log(1, MSG_NOTICE, format); } while(0)
-
-#define log_at_warn(format...) \
-do { print_log(1, MSG_WARN, format); } while(0)
-
-#define log_at_err(format...) \
-do { print_log(1, MSG_ERROR, format); } while(0)
-
-#define log_at_crit(format...) \
-do { print_log(1, MSG_CRITICAL, format); } while(0)
-
extern char gfs2_getch(void);
extern void increase_verbosity(void);
extern void decrease_verbosity(void);
-extern void print_fsck_log(int iif, int priority, const char *file, int line,
+extern void print_fsck_log(int priority, const char *file, int line,
const char *format, ...)
- __attribute__((format(printf,5,6)));
+ __attribute__((format(printf,4,5)));
extern char generic_interrupt(const char *caller, const char *where,
const char *progress, const char *question,
const char *answers);