summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/urweb.h2
-rw-r--r--src/c/request.c2
-rw-r--r--src/c/urweb.c14
-rw-r--r--tests/hog.ur4
4 files changed, 16 insertions, 6 deletions
diff --git a/include/urweb.h b/include/urweb.h
index a7920851..9527fac1 100644
--- a/include/urweb.h
+++ b/include/urweb.h
@@ -20,7 +20,7 @@ void uw_client_connect(unsigned id, int pass, int sock,
void uw_prune_clients(uw_context);
failure_kind uw_initialize(uw_context);
-uw_context uw_init(void);
+uw_context uw_init(void *logger_data, uw_logger log_debug);
void uw_close(uw_context);
int uw_set_app(uw_context, uw_app*);
uw_app *uw_get_app(uw_context);
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;
}
diff --git a/tests/hog.ur b/tests/hog.ur
index 419d202d..cd666cbe 100644
--- a/tests/hog.ur
+++ b/tests/hog.ur
@@ -4,4 +4,6 @@ fun more n =
else
more (n-1) ^ more (n-1)
-fun main n = return <xml>{[more n]}</xml>
+fun main n =
+ debug "Let's give this a try....";
+ return <xml>{[more n]}</xml>