Skip to content

Commit 7a3acd6

Browse files
authored
bugfix: stream server block didn't inherit the log_by_lua* directives configured in stream block.
1 parent d23c278 commit 7a3acd6

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/ngx_stream_lua_module.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,6 +1002,13 @@ ngx_stream_lua_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child)
10021002
conf->preread_chunkname = prev->preread_chunkname;
10031003
}
10041004

1005+
if (conf->log_src.value.len == 0) {
1006+
conf->log_src = prev->log_src;
1007+
conf->log_handler = prev->log_handler;
1008+
conf->log_src_key = prev->log_src_key;
1009+
conf->log_chunkname = prev->log_chunkname;
1010+
}
1011+
10051012
return NGX_CONF_OK;
10061013
}
10071014

t/075-logby.t

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,3 +363,17 @@ log handler
363363
ok
364364
--- no_error_log
365365
[error]
366+
367+
368+
369+
=== TEST 21: log_by_lua in stream level
370+
--- stream_config
371+
log_by_lua_block { ngx.log(ngx.ERR, "Hello from log_by_lua stream level: ", ngx.var.protocol) }
372+
--- stream_server_config
373+
content_by_lua_block {
374+
ngx.say('hello')
375+
}
376+
--- stream_response
377+
hello
378+
--- error_log
379+
Hello from log_by_lua stream level: TCP

0 commit comments

Comments
 (0)