[PATCH 1/3] TEST: properly clear the filters
by Angus Salkeld
Signed-off-by: Angus Salkeld <asalkeld(a)redhat.com>
---
tests/check_log.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/tests/check_log.c b/tests/check_log.c
index 4b06e67..705d66a 100644
--- a/tests/check_log.c
+++ b/tests/check_log.c
@@ -269,7 +269,7 @@ START_TEST(test_log_basic)
* test filtering by function
*/
qb_log_filter_ctl(t, QB_LOG_FILTER_CLEAR_ALL,
- QB_LOG_FILTER_FILE, "*", LOG_DEBUG);
+ QB_LOG_FILTER_FILE, "*", LOG_TRACE);
qb_log_filter_ctl(t, QB_LOG_FILTER_ADD,
QB_LOG_FILTER_FUNCTION, "log_it_please", LOG_WARNING);
@@ -290,7 +290,7 @@ START_TEST(test_log_basic)
ck_assert_int_eq(num_msgs, 1);
qb_log_filter_ctl(t, QB_LOG_FILTER_CLEAR_ALL,
- QB_LOG_FILTER_FILE, "*", LOG_DEBUG);
+ QB_LOG_FILTER_FILE, "*", LOG_TRACE);
qb_log_filter_ctl(t, QB_LOG_FILTER_ADD,
QB_LOG_FILTER_FUNCTION,
"log_also,log_and_this_too",
@@ -301,7 +301,7 @@ START_TEST(test_log_basic)
ck_assert_int_eq(num_msgs, 2);
qb_log_filter_ctl(t, QB_LOG_FILTER_CLEAR_ALL,
- QB_LOG_FILTER_FILE, "*", LOG_DEBUG);
+ QB_LOG_FILTER_FILE, "*", LOG_TRACE);
qb_log_filter_ctl(t, QB_LOG_FILTER_ADD,
QB_LOG_FILTER_FILE, __FILE__, LOG_DEBUG);
/*
@@ -330,7 +330,7 @@ START_TEST(test_log_basic)
* log level.
*/
qb_log_filter_ctl(t, QB_LOG_FILTER_CLEAR_ALL,
- QB_LOG_FILTER_FILE, "*", LOG_DEBUG);
+ QB_LOG_FILTER_FILE, "*", LOG_TRACE);
qb_log_filter_ctl(t, QB_LOG_FILTER_ADD,
QB_LOG_FILTER_FILE, __FILE__, LOG_INFO);
--
1.7.9.1
12 years, 2 months
[PATCH] LOG: expose the mechanism to get a dynamic callsite.
by Angus Salkeld
Signed-off-by: Angus Salkeld <asalkeld(a)redhat.com>
---
include/qb/qblog.h | 48 +++++++++++++++++++++++++++++++++++-------------
lib/log.c | 47 ++++++++++++++++++++++++++++++++++++-----------
2 files changed, 71 insertions(+), 24 deletions(-)
diff --git a/include/qb/qblog.h b/include/qb/qblog.h
index 7a8c66d..1b88f18 100644
--- a/include/qb/qblog.h
+++ b/include/qb/qblog.h
@@ -228,11 +228,11 @@ typedef const char *(*qb_log_tags_stringify_fn)(uint32_t tags);
* the special section is treated as an array of these.
*/
struct qb_log_callsite {
- const char *function;
- const char *filename;
- const char *format;
+ const char *function;
+ const char *filename;
+ const char *format;
uint8_t priority;
- uint32_t lineno;
+ uint32_t lineno;
uint32_t targets;
uint32_t tags;
} __attribute__((aligned(8)));
@@ -287,13 +287,32 @@ void qb_log_from_external_source(const char *function,
uint32_t tags,
...);
+/**
+ * Get or create a callsite at the give position.
+ *
+ * The result can then be passed into qb_log_real_()
+ *
+ * @param function originating function name
+ * @param filename originating filename
+ * @param format format string
+ * @param priority this takes syslog priorities.
+ * @param lineno file line number
+ * @param tags the tag
+ */
+struct qb_log_callsite* qb_log_callsite_get(const char *function,
+ const char *filename,
+ const char *format,
+ uint8_t priority,
+ uint32_t lineno,
+ uint32_t tags);
+
void qb_log_from_external_source_va(const char *function,
- const char *filename,
- const char *format,
- uint8_t priority,
- uint32_t lineno,
- uint32_t tags,
- va_list ap);
+ const char *filename,
+ const char *format,
+ uint8_t priority,
+ uint32_t lineno,
+ uint32_t tags,
+ va_list ap);
/**
* This is the function to generate a log message if you want to
@@ -315,12 +334,15 @@ void qb_log_from_external_source_va(const char *function,
qb_log_real_(&descriptor, ##args); \
} while(0)
#else
-#define qb_logt(priority, tags, fmt, args...) do { \
- qb_log_from_external_source(__func__, __FILE__, fmt, priority, \
- __LINE__, tags, ##args); \
+#define qb_logt(priority, tags, fmt, args...) do { \
+ struct qb_log_callsite* descriptor_pt = \
+ qb_log_callsite_get(__func__, __FILE__, fmt, \
+ priority, __LINE__, tags); \
+ qb_log_real_(descriptor_pt, ##args); \
} while(0)
#endif /* QB_HAVE_ATTRIBUTE_SECTION */
+
/**
* This is the main function to generate a log message.
*
diff --git a/lib/log.c b/lib/log.c
index 0101bc6..4056b1f 100644
--- a/lib/log.c
+++ b/lib/log.c
@@ -133,7 +133,7 @@ qb_log_real_va_(struct qb_log_callsite *cs, va_list ap)
char *str = buf;
va_list ap_copy;
- if (in_logger) {
+ if (in_logger || cs == NULL) {
return;
}
in_logger = QB_TRUE;
@@ -234,12 +234,13 @@ qb_log_thread_log_write(struct qb_log_callsite *cs,
}
}
-void
-qb_log_from_external_source_va(const char *function,
- const char *filename,
- const char *format,
- uint8_t priority,
- uint32_t lineno, uint32_t tags, va_list ap)
+struct qb_log_callsite*
+qb_log_callsite_get(const char *function,
+ const char *filename,
+ const char *format,
+ uint8_t priority,
+ uint32_t lineno,
+ uint32_t tags)
{
struct qb_log_target *t;
struct qb_log_filter *flt;
@@ -249,13 +250,13 @@ qb_log_from_external_source_va(const char *function,
int32_t pos;
if (!logger_inited) {
- return;
+ return NULL;
}
cs = qb_log_dcs_get(&new_dcs, function, filename,
format, priority, lineno, tags);
if (cs == NULL) {
- return;
+ return NULL;
}
if (new_dcs) {
@@ -287,6 +288,24 @@ qb_log_from_external_source_va(const char *function,
}
pthread_rwlock_unlock(&_listlock);
}
+ return cs;
+}
+
+void
+qb_log_from_external_source_va(const char *function,
+ const char *filename,
+ const char *format,
+ uint8_t priority,
+ uint32_t lineno, uint32_t tags, va_list ap)
+{
+ struct qb_log_callsite *cs;
+
+ if (!logger_inited) {
+ return;
+ }
+
+ cs = qb_log_callsite_get(function, filename,
+ format, priority, lineno, tags);
qb_log_real_va_(cs, ap);
}
@@ -297,11 +316,17 @@ qb_log_from_external_source(const char *function,
uint8_t priority,
uint32_t lineno, uint32_t tags, ...)
{
+ struct qb_log_callsite *cs;
va_list ap;
+ if (!logger_inited) {
+ return;
+ }
+
+ cs = qb_log_callsite_get(function, filename,
+ format, priority, lineno, tags);
va_start(ap, tags);
- qb_log_from_external_source_va(function, filename, format, priority,
- lineno, tags, ap);
+ qb_log_real_va_(cs, ap);
va_end(ap);
}
--
1.7.9.1
12 years, 2 months
[PATCH] Fix "make rpm" for a dirty source tree.
by Russell Bryant
If there are local changes, "make rpm" fails. This is because the
tarball that gets exported doesn't have "-dirty" in it. This is one
possible fix. The other is to change the name of the tarball.
Signed-off-by: Russell Bryant <rbryant(a)redhat.com>
---
libqb.spec.in | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/libqb.spec.in b/libqb.spec.in
index f734656..bc287c3 100644
--- a/libqb.spec.in
+++ b/libqb.spec.in
@@ -10,7 +10,7 @@ Summary: An IPC library for high performance servers.
Group: System Environment/Libraries
License: LGPLv2+
URL: http://www.libqb.org
-Source0: https://fedorahosted.org/releases/q/u/quarterback/%{name}-%{version}%{?nu...
+Source0: https://fedorahosted.org/releases/q/u/quarterback/%{name}-%{version}%{?nu...
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: autoconf automake libtool doxygen procps check-devel
@@ -20,7 +20,7 @@ libqb provides high performance client server reusable features.
Initially these are IPC and poll.
%prep
-%setup -q -n %{name}-%{version}%{?numcomm:.%{numcomm}}%{?alphatag:-%{alphatag}}%{?dirty:-%{dirty}}
+%setup -q -n %{name}-%{version}%{?numcomm:.%{numcomm}}%{?alphatag:-%{alphatag}}
%build
./autogen.sh
--
1.7.7.6
12 years, 2 months