From d86e0a7aec86bf2ed472aec3a69dd17a34329301 Mon Sep 17 00:00:00 2001 From: Valentin Bartenev Date: Tue, 21 Jul 2020 20:27:37 +0300 Subject: [PATCH] PHP: logging in request context when possible. --- src/nxt_php_sapi.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/nxt_php_sapi.c b/src/nxt_php_sapi.c index ab888f57..ee0976ce 100644 --- a/src/nxt_php_sapi.c +++ b/src/nxt_php_sapi.c @@ -1277,6 +1277,16 @@ static void nxt_php_log_message(char *message TSRMLS_DC) #endif { - nxt_unit_log(nxt_php_unit_ctx, NXT_UNIT_LOG_NOTICE, - "php message: %s", message); + nxt_php_run_ctx_t *ctx; + + ctx = SG(server_context); + + if (ctx != NULL) { + nxt_unit_req_log(ctx->req, NXT_UNIT_LOG_NOTICE, + "php message: %s", message); + + } else { + nxt_unit_log(nxt_php_unit_ctx, NXT_UNIT_LOG_NOTICE, + "php message: %s", message); + } }