From 023488cde9c968df265df1bd8b2358f5c2216115 Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Sun, 12 Dec 2010 10:35:04 -0500 Subject: Change Basis.debug to use the protocol's debug function --- src/c/request.c | 2 +- src/c/urweb.c | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/c/request.c b/src/c/request.c index ae46326d..bcfec5e9 100644 --- a/src/c/request.c +++ b/src/c/request.c @@ -35,7 +35,7 @@ static int try_rollback(uw_context ctx, int will_retry, void *logger_data, uw_lo } uw_context uw_request_new_context(uw_app *app, void *logger_data, uw_logger log_error, uw_logger log_debug) { - uw_context ctx = uw_init(); + uw_context ctx = uw_init(logger_data, log_debug); int retries_left = MAX_RETRIES; uw_set_app(ctx, app); diff --git a/src/c/urweb.c b/src/c/urweb.c index b4a15bce..47c6dadf 100644 --- a/src/c/urweb.c +++ b/src/c/urweb.c @@ -442,6 +442,9 @@ struct uw_context { void *client_data; + void *logger_data; + uw_logger log_debug; + char error_message[ERROR_BUF_LEN]; }; @@ -450,7 +453,7 @@ size_t uw_page_max = SIZE_MAX; size_t uw_heap_max = SIZE_MAX; size_t uw_script_max = SIZE_MAX; -uw_context uw_init() { +uw_context uw_init(void *logger_data, uw_logger log_debug) { uw_context ctx = malloc(sizeof(struct uw_context)); ctx->app = NULL; @@ -501,6 +504,9 @@ uw_context uw_init() { ctx->client_data = uw_init_client_data(); + ctx->logger_data = logger_data; + ctx->log_debug = log_debug; + return ctx; } @@ -3441,8 +3447,10 @@ void uw_check_deadline(uw_context ctx) { size_t uw_database_max = SIZE_MAX; uw_Basis_unit uw_Basis_debug(uw_context ctx, uw_Basis_string s) { - fprintf(stderr, "%s\n", s); - + if (ctx->log_debug) + ctx->log_debug(ctx->logger_data, "%s\n", s); + else + fprintf(stderr, "%s\n", s); return uw_unit_v; } -- cgit v1.2.3