/* Default log handler. */ int _assuan_log_handler (assuan_context_t ctx, void *hook, unsigned int cat, const char *msg) { FILE *fp; const char *prf; int saved_errno = errno; /* For now. */ if (msg == NULL) return TEST_LOG_CAT (cat); if (! TEST_LOG_CAT (cat)) return 0; fp = ctx->log_fp ? ctx->log_fp : _assuan_log; if (!fp) return 0; prf = assuan_get_assuan_log_prefix (); if (*prf) fprintf (fp, "%s[%u]: ", prf, (unsigned int)getpid ()); fprintf (fp, "%s", msg); /* If the log stream is a file, the output would be buffered. This is bad for debugging, thus we flush the stream if FORMAT ends with a LF. */ if (msg && *msg && msg[strlen (msg) - 1] == '\n') fflush (fp); errno = saved_errno; return 0; }
static int my_libassuan_log_handler (assuan_context_t ctx, void *hook, unsigned int cat, const char *msg) { unsigned int dbgval; (void)ctx; if (! TEST_LOG_CAT (cat)) return 0; dbgval = hook? *(unsigned int*)hook : 0; if (!(dbgval & 1024)) return 0; /* Assuan debugging is not enabled. */ if (msg) log_string (JNLIB_LOG_DEBUG, msg); return 1; }