diff options
author | Marcus Brinkmann <[email protected]> | 2009-12-03 18:55:16 +0000 |
---|---|---|
committer | Marcus Brinkmann <[email protected]> | 2009-12-03 18:55:16 +0000 |
commit | 58ddb0411a61dd3bd77267a1dc9336d5c3c579d5 (patch) | |
tree | 4309e12e03e943e6e8830b4bc302e4015cd834c7 | |
parent | src/ (diff) | |
download | libassuan-58ddb0411a61dd3bd77267a1dc9336d5c3c579d5.tar.gz libassuan-58ddb0411a61dd3bd77267a1dc9336d5c3c579d5.zip |
2009-12-03 Marcus Brinkmann <[email protected]>
* assuan-logging.c: (log_cats): New static variable.
(TEST_LOG_CAT): New macro.
(_assuan_log_handler): Check log category.
(assuan_set_assuan_log_stream): Check ASSUAN_DEBUG for logging
categories.
(assuan_set_log_stream): Call assuan_set_assuan_log_stream.
-rw-r--r-- | src/ChangeLog | 9 | ||||
-rw-r--r-- | src/assuan-logging.c | 21 |
2 files changed, 28 insertions, 2 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 45a849b..fae9d9f 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,12 @@ +2009-12-03 Marcus Brinkmann <[email protected]> + + * assuan-logging.c: (log_cats): New static variable. + (TEST_LOG_CAT): New macro. + (_assuan_log_handler): Check log category. + (assuan_set_assuan_log_stream): Check ASSUAN_DEBUG for logging + categories. + (assuan_set_log_stream): Call assuan_set_assuan_log_stream. + 2009-12-02 Marcus Brinkmann <[email protected]> * Makefile.am (common_sources): Remove assuan-client.c. diff --git a/src/assuan-logging.c b/src/assuan-logging.c index fa2e3c2..5d9d488 100644 --- a/src/assuan-logging.c +++ b/src/assuan-logging.c @@ -44,14 +44,27 @@ static char prefix_buffer[80]; logging of buffer data. */ static int full_logging; +/* A bitfield that specifies the categories to log. Note that + assuan-buffer currently does not log through the default handler, + but directly. This will be changed later. Then the default here + should be to log that and only that. */ +static int log_cats; +#define TEST_LOG_CAT(x) (!! (log_cats & (1 << (x - 1)))) static FILE *_assuan_log; void assuan_set_assuan_log_stream (FILE *fp) { + char *flagstr; + _assuan_log = fp; + + /* Set defaults. */ full_logging = !!getenv ("ASSUAN_FULL_LOGGING"); + flagstr = getenv ("ASSUAN_DEBUG"); + if (flagstr) + log_cats = atoi (flagstr); } @@ -65,7 +78,8 @@ assuan_set_log_stream (assuan_context_t ctx, FILE *fp) if (ctx->log_fp) fflush (ctx->log_fp); ctx->log_fp = fp; - full_logging = !!getenv ("ASSUAN_FULL_LOGGING"); + if (! _assuan_log) + assuan_set_assuan_log_stream (fp); } } @@ -104,7 +118,10 @@ _assuan_log_handler (assuan_context_t ctx, void *hook, unsigned int cat, /* For now. */ if (msg == NULL) - return 1; + return TEST_LOG_CAT (cat); + + if (! TEST_LOG_CAT (cat)) + return 0; fp = ctx->log_fp ? ctx->log_fp : _assuan_log; if (!fp) |