cluster: RHEL56 - libgfs2: gfs2_log reform
Bob Peterson
rpeterso at fedoraproject.org
Sat Apr 10 04:52:41 UTC 2010
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=7079b2141b66a78e0484d56025ad3e6c238a021c
Commit: 7079b2141b66a78e0484d56025ad3e6c238a021c
Parent: 7d8b8ae7f3f3a425c11b58def216d45881e36ac9
Author: Bob Peterson <bob at ganesha.peterson>
AuthorDate: Thu Jan 21 09:07:45 2010 -0600
Committer: Bob Peterson <rpeterso at redhat.com>
CommitterDate: Fri Apr 9 23:33:16 2010 -0500
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 d3cf7e5..73d059b 100644
--- a/gfs2/libgfs2/gfs2_log.c
+++ b/gfs2/libgfs2/gfs2_log.c
@@ -24,19 +24,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--;
}
void print_msg(int priority, const char *file, int line, const char *format,
@@ -45,9 +42,8 @@ void print_msg(int priority, const char *file, int line, const char *format,
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:
@@ -64,7 +60,7 @@ void print_msg(int priority, const char *file, int line, const char *format,
}
-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;
@@ -72,11 +68,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 1cd441f..726dd86 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -531,6 +531,8 @@ struct gfs2_options {
int query:1;
};
+extern int print_level;
+
#define MSG_DEBUG 7
#define MSG_INFO 6
#define MSG_NOTICE 5
@@ -539,52 +541,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);
More information about the cluster-commits
mailing list