summaryrefslogtreecommitdiff
path: root/qpid/extras/dispatch/src/log.c
diff options
context:
space:
mode:
authorTed Ross <tross@apache.org>2013-05-02 20:58:23 +0000
committerTed Ross <tross@apache.org>2013-05-02 20:58:23 +0000
commitd83fef53fc84ec40fc02be778a05d738b0d5b0b9 (patch)
tree46ba7559c2ed36d39c23074061862563a6a73601 /qpid/extras/dispatch/src/log.c
parente92ff34198ad8a5e7ab1bab006dbe1db6aebc6e0 (diff)
downloadqpid-python-d83fef53fc84ec40fc02be778a05d738b0d5b0b9.tar.gz
NO-JIRA - Additional Development
- Added buffer of saved log messages for remote retrieval. - Added __FILE__ and __LINE__ annotations to logs. - Refactored dx_message_check() so it can be called multiple times with different depths. - Separated the buffer-size-specific tests into a separate unit test executable. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1478538 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/extras/dispatch/src/log.c')
-rw-r--r--qpid/extras/dispatch/src/log.c26
1 files changed, 19 insertions, 7 deletions
diff --git a/qpid/extras/dispatch/src/log.c b/qpid/extras/dispatch/src/log.c
index c6cffe0321..711d478e32 100644
--- a/qpid/extras/dispatch/src/log.c
+++ b/qpid/extras/dispatch/src/log.c
@@ -17,9 +17,10 @@
* under the License.
*/
-#include <qpid/dispatch/log.h>
+#include "log_private.h"
#include <qpid/dispatch/ctools.h>
#include <qpid/dispatch/alloc.h>
+#include <qpid/dispatch/threading.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
@@ -47,7 +48,8 @@ DEQ_DECLARE(dx_log_entry_t, dx_log_list_t);
static int mask = LOG_INFO;
static dx_log_list_t entries;
-static int list_init = 0;
+static sys_mutex_t *log_lock = 0;
+
static char *cls_prefix(int cls)
{
@@ -65,11 +67,6 @@ void dx_log_impl(const char *module, int cls, const char *file, int line, const
if (!(cls & mask))
return;
- if (list_init == 0) {
- list_init = 1;
- DEQ_INIT(entries);
- }
-
dx_log_entry_t *entry = new_dx_log_entry_t();
entry->module = module;
entry->cls = cls;
@@ -84,12 +81,14 @@ void dx_log_impl(const char *module, int cls, const char *file, int line, const
va_end(ap);
fprintf(stderr, "%s (%s) %s\n", module, cls_prefix(cls), entry->text);
+ sys_mutex_lock(log_lock);
DEQ_INSERT_TAIL(entries, entry);
if (DEQ_SIZE(entries) > LIST_MAX) {
entry = DEQ_HEAD(entries);
DEQ_REMOVE_HEAD(entries);
free_dx_log_entry_t(entry);
}
+ sys_mutex_unlock(log_lock);
}
void dx_log_set_mask(int _mask)
@@ -97,3 +96,16 @@ void dx_log_set_mask(int _mask)
mask = _mask;
}
+
+void dx_log_initialize(void)
+{
+ DEQ_INIT(entries);
+ log_lock = sys_mutex();
+}
+
+
+void dx_log_finalize(void)
+{
+}
+
+