From: Dmitry Volyntsev Date: Sat, 9 Sep 2023 00:13:19 +0000 (-0700) Subject: Modules: improved debug log. X-Git-Tag: 0.8.1~3 X-Git-Url: http://www.kaiwu.me/postgresql/commit/?a=commitdiff_plain;h=036c785984d12745f468bc307d374446b4cb6415;p=njs.git Modules: improved debug log. 1) Ensuring that consistent prefixes are used: "http js" in HTTP module and "stream js" in Stream module. 2) Added debug for every event/callback handler entrance. 3) Added debug with a method name for every JS call. --- diff --git a/nginx/ngx_http_js_module.c b/nginx/ngx_http_js_module.c index 2574a3be..f8811617 100644 --- a/nginx/ngx_http_js_module.c +++ b/nginx/ngx_http_js_module.c @@ -1075,6 +1075,9 @@ ngx_http_js_header_filter(ngx_http_request_t *r) return ngx_http_next_header_filter(r); } + ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, + "http js header filter"); + rc = ngx_http_js_init_vm(r, ngx_http_js_request_proto_id); if (rc == NGX_ERROR || rc == NGX_DECLINED) { @@ -1086,6 +1089,9 @@ ngx_http_js_header_filter(ngx_http_request_t *r) ctx->filter = 1; pending = njs_vm_pending(ctx->vm); + ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, + "http js header call \"%V\"", &jlcf->header_filter); + rc = ngx_js_call(ctx->vm, &jlcf->header_filter, r->connection->log, &ctx->request, 1); @@ -1127,6 +1133,9 @@ ngx_http_js_body_filter(ngx_http_request_t *r, ngx_chain_t *in) return ngx_http_next_body_filter(r, in); } + ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, + "http js body filter"); + rc = ngx_http_js_init_vm(r, ngx_http_js_request_proto_id); if (rc == NGX_ERROR || rc == NGX_DECLINED) { @@ -1183,6 +1192,9 @@ ngx_http_js_body_filter(ngx_http_request_t *r, ngx_chain_t *in) pending = njs_vm_pending(ctx->vm); + ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, + "http js body call \"%V\"", &jlcf->body_filter); + rc = ngx_js_call(ctx->vm, &jlcf->body_filter, c->log, &arguments[0], 3); diff --git a/nginx/ngx_stream_js_module.c b/nginx/ngx_stream_js_module.c index 6e28f4ab..a0f1de5d 100644 --- a/nginx/ngx_stream_js_module.c +++ b/nginx/ngx_stream_js_module.c @@ -722,6 +722,9 @@ ngx_stream_js_phase_handler(ngx_stream_session_t *s, ngx_str_t *name) return NGX_DECLINED; } + ngx_log_debug0(NGX_LOG_DEBUG_STREAM, s->connection->log, 0, + "stream js phase handler"); + rc = ngx_stream_js_init_vm(s, ngx_stream_js_session_proto_id); if (rc != NGX_OK) { return rc; @@ -729,9 +732,6 @@ ngx_stream_js_phase_handler(ngx_stream_session_t *s, ngx_str_t *name) c = s->connection; - ngx_log_debug1(NGX_LOG_DEBUG_STREAM, c->log, 0, - "stream js phase call \"%V\"", name); - ctx = ngx_stream_get_module_ctx(s, ngx_stream_js_module); if (!ctx->in_progress) { @@ -742,6 +742,9 @@ ngx_stream_js_phase_handler(ngx_stream_session_t *s, ngx_str_t *name) ctx->status = NGX_ERROR; + ngx_log_debug1(NGX_LOG_DEBUG_STREAM, c->log, 0, + "stream js phase call \"%V\"", name); + rc = ngx_js_call(ctx->vm, name, c->log, &ctx->args[0], 1); if (rc == NGX_ERROR) { @@ -816,6 +819,9 @@ ngx_stream_js_body_filter(ngx_stream_session_t *s, ngx_chain_t *in, ctx = ngx_stream_get_module_ctx(s, ngx_stream_js_module); if (!ctx->filter) { + ngx_log_debug1(NGX_LOG_DEBUG_STREAM, c->log, 0, + "stream js filter call \"%V\"" , &jscf->filter); + rc = ngx_js_call(ctx->vm, &jscf->filter, c->log, &ctx->args[0], 1); if (rc == NGX_ERROR) { @@ -1899,8 +1905,8 @@ ngx_stream_js_periodic_handler(ngx_event_t *ev) if (c != NULL) { ngx_log_error(NGX_LOG_ERR, c->log, 0, - "js periodic \"%V\" is already running, killing previous " - "instance", &periodic->method); + "stream js periodic \"%V\" is already running, killing " + "previous instance", &periodic->method); ngx_stream_js_periodic_finalize(c->data, NGX_ERROR); }