[njs] Modules: fixed nginx logger callback for calls in master.
Dmitry Volyntsev
xeioex at nginx.com
Tue Dec 13 17:13:17 UTC 2022
details: https://hg.nginx.org/njs/rev/f23c541c02ad
branches:
changeset: 2014:f23c541c02ad
user: Dmitry Volyntsev <xeioex at nginx.com>
date: Mon Dec 12 21:55:47 2022 -0800
description:
Modules: fixed nginx logger callback for calls in master.
diffstat:
nginx/ngx_js.c | 24 +++++++++++++++++++-----
1 files changed, 19 insertions(+), 5 deletions(-)
diffs (39 lines):
diff -r 23607989a28b -r f23c541c02ad nginx/ngx_js.c
--- a/nginx/ngx_js.c Wed Dec 07 18:11:57 2022 -0800
+++ b/nginx/ngx_js.c Mon Dec 12 21:55:47 2022 -0800
@@ -376,16 +376,30 @@ void
ngx_js_logger(njs_vm_t *vm, njs_external_ptr_t external, njs_log_level_t level,
const u_char *start, size_t length)
{
+ ngx_log_t *log;
ngx_connection_t *c;
ngx_log_handler_pt handler;
- c = ngx_external_connection(vm, external);
- handler = c->log->handler;
- c->log->handler = NULL;
+ handler = NULL;
+
+ if (external != NULL) {
+ c = ngx_external_connection(vm, external);
+ log = c->log;
+ handler = log->handler;
+ log->handler = NULL;
+
+ } else {
- ngx_log_error((ngx_uint_t) level, c->log, 0, "js: %*s", length, start);
+ /* Logger was called during init phase. */
+
+ log = ngx_cycle->log;
+ }
- c->log->handler = handler;
+ ngx_log_error((ngx_uint_t) level, log, 0, "js: %*s", length, start);
+
+ if (external != NULL) {
+ log->handler = handler;
+ }
}
More information about the nginx-devel
mailing list