Commit aefa6489 authored by Geoff Simmons's avatar Geoff Simmons

Add a gcrypt log handler

parent 47b8f79f
......@@ -95,6 +95,45 @@ errmsg(VRT_CTX, const char *fmt, ...)
/* Event function */
static void __match_proto__(gcry_handler_log_t)
gcrypt_logger(void *priv, int level, const char *fmt, va_list args)
{
enum VSL_tag_e tag = SLT_Debug;
const char *lvl = "INFO";
(void) priv;
switch(level) {
case GCRY_LOG_CONT:
lvl = "continuation";
break;
case GCRY_LOG_INFO:
lvl = "INFO";
break;
case GCRY_LOG_WARN:
lvl = "WARN";
break;
case GCRY_LOG_ERROR:
lvl = "ERROR";
tag = SLT_Error;
break;
case GCRY_LOG_FATAL:
lvl = "FATAL";
tag = SLT_Error;
break;
case GCRY_LOG_BUG:
lvl = "BUG";
tag = SLT_Error;
break;
case GCRY_LOG_DEBUG:
lvl = "DEBUG";
break;
default:
VSL(SLT_Error, 0, "Unknown gcrypt log level %d", level);
}
VSL(tag, 0, "libgcrypt log message follows (%s):", lvl);
VSLv(tag, 0, fmt, args);
}
int __match_proto__(vmod_event_f)
event(VRT_CTX, struct vmod_priv *priv, enum vcl_event_e e)
{
......@@ -102,9 +141,13 @@ event(VRT_CTX, struct vmod_priv *priv, enum vcl_event_e e)
(void) priv;
if (e == VCL_EVENT_LOAD) {
if (gcrypt_version != NULL)
return 0;
gcry_set_log_handler(gcrypt_logger, NULL);
gcrypt_version = gcry_check_version(MIN_GCRYPT_VERSION);
if (gcrypt_version == NULL) {
// XXX log error
VSL(SLT_VCL_Error, 0,
"libgcrypt initialization failed");
return 1;
}
/* XXX other initialization */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment