-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(dynamic_log_level): support timeout for dynamic log level
Co-authored-by: Murillo <103451714+gruceo@users.noreply.github.com> Co-authored-by: Chrono <chrono_cpp@me.com>
- Loading branch information
1 parent
a6bc93a
commit d52bddc
Showing
11 changed files
with
406 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
133 changes: 133 additions & 0 deletions
133
build/openresty/patches/nginx-1.21.4_06-dynamic_log_level.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
diff --git a/bundle/nginx-1.21.4/src/core/ngx_log.c b/bundle/nginx-1.21.4/src/core/ngx_log.c | ||
index eb7a989..0862d4d 100644 | ||
--- a/bundle/nginx-1.21.4/src/core/ngx_log.c | ||
+++ b/bundle/nginx-1.21.4/src/core/ngx_log.c | ||
@@ -171,8 +171,12 @@ ngx_log_error_core(ngx_uint_t level, ngx_log_t *log, ngx_err_t err, | ||
debug_connection = (log->log_level & NGX_LOG_DEBUG_CONNECTION) != 0; | ||
|
||
while (log) { | ||
- | ||
+#if (NGX_HTTP_LUA_KONG) | ||
+ if (ngx_http_lua_kong_get_dynamic_log_level(log->log_level) < level && | ||
+ !debug_connection) { | ||
+#else | ||
if (log->log_level < level && !debug_connection) { | ||
+#endif | ||
break; | ||
} | ||
|
||
@@ -230,7 +234,11 @@ ngx_log_error(ngx_uint_t level, ngx_log_t *log, ngx_err_t err, | ||
{ | ||
va_list args; | ||
|
||
+#if (NGX_HTTP_LUA_KONG) | ||
+ if (ngx_http_lua_kong_get_dynamic_log_level(log->log_level) >= level) { | ||
+#else | ||
if (log->log_level >= level) { | ||
+#endif | ||
va_start(args, fmt); | ||
ngx_log_error_core(level, log, err, fmt, args); | ||
va_end(args); | ||
diff --git a/bundle/nginx-1.21.4/src/core/ngx_log.h b/bundle/nginx-1.21.4/src/core/ngx_log.h | ||
index da81cf0..8fd3348 100644 | ||
--- a/bundle/nginx-1.21.4/src/core/ngx_log.h | ||
+++ b/bundle/nginx-1.21.4/src/core/ngx_log.h | ||
@@ -72,6 +72,13 @@ struct ngx_log_s { | ||
ngx_log_t *next; | ||
}; | ||
|
||
+#if (NGX_HTTP_LUA_KONG) | ||
+ngx_uint_t | ||
+ngx_http_lua_kong_get_dynamic_log_level(ngx_uint_t current_log_level); | ||
+#else | ||
+#define ngx_http_lua_kong_get_dynamic_log_level(expr) (expr) | ||
+#endif | ||
+ | ||
|
||
#ifndef NGX_MAX_ERROR_STR | ||
#define NGX_MAX_ERROR_STR 4096 | ||
@@ -85,13 +92,13 @@ struct ngx_log_s { | ||
#define NGX_HAVE_VARIADIC_MACROS 1 | ||
|
||
#define ngx_log_error(level, log, ...) \ | ||
- if ((log)->log_level >= level) ngx_log_error_core(level, log, __VA_ARGS__) | ||
+ if (ngx_http_lua_kong_get_dynamic_log_level((log)->log_level) >= level) ngx_log_error_core(level, log, __VA_ARGS__) | ||
|
||
void ngx_log_error_core(ngx_uint_t level, ngx_log_t *log, ngx_err_t err, | ||
const char *fmt, ...); | ||
|
||
#define ngx_log_debug(level, log, ...) \ | ||
- if ((log)->log_level & level) \ | ||
+ if (ngx_http_lua_kong_get_dynamic_log_level((log)->log_level) & level) \ | ||
ngx_log_error_core(NGX_LOG_DEBUG, log, __VA_ARGS__) | ||
|
||
/*********************************/ | ||
@@ -101,13 +108,13 @@ void ngx_log_error_core(ngx_uint_t level, ngx_log_t *log, ngx_err_t err, | ||
#define NGX_HAVE_VARIADIC_MACROS 1 | ||
|
||
#define ngx_log_error(level, log, args...) \ | ||
- if ((log)->log_level >= level) ngx_log_error_core(level, log, args) | ||
+ if (ngx_http_lua_kong_get_dynamic_log_level((log)->log_level) >= level) ngx_log_error_core(level, log, args) | ||
|
||
void ngx_log_error_core(ngx_uint_t level, ngx_log_t *log, ngx_err_t err, | ||
const char *fmt, ...); | ||
|
||
#define ngx_log_debug(level, log, args...) \ | ||
- if ((log)->log_level & level) \ | ||
+ if (ngx_http_lua_kong_get_dynamic_log_level((log)->log_level) & level) ngx_log_error_core(level, log, args) | ||
ngx_log_error_core(NGX_LOG_DEBUG, log, args) | ||
|
||
/*********************************/ | ||
@@ -170,43 +177,43 @@ void ngx_cdecl ngx_log_debug_core(ngx_log_t *log, ngx_err_t err, | ||
#else /* no variadic macros */ | ||
|
||
#define ngx_log_debug0(level, log, err, fmt) \ | ||
- if ((log)->log_level & level) \ | ||
+ if (ngx_http_lua_kong_get_dynamic_log_level((log)->log_level) & level) \ | ||
ngx_log_debug_core(log, err, fmt) | ||
|
||
#define ngx_log_debug1(level, log, err, fmt, arg1) \ | ||
- if ((log)->log_level & level) \ | ||
+ if (ngx_http_lua_kong_get_dynamic_log_level((log)->log_level) & level) \ | ||
ngx_log_debug_core(log, err, fmt, arg1) | ||
|
||
#define ngx_log_debug2(level, log, err, fmt, arg1, arg2) \ | ||
- if ((log)->log_level & level) \ | ||
+ if (ngx_http_lua_kong_get_dynamic_log_level((log)->log_level) & level) \ | ||
ngx_log_debug_core(log, err, fmt, arg1, arg2) | ||
|
||
#define ngx_log_debug3(level, log, err, fmt, arg1, arg2, arg3) \ | ||
- if ((log)->log_level & level) \ | ||
+ if (ngx_http_lua_kong_get_dynamic_log_level((log)->log_level) & level) \ | ||
ngx_log_debug_core(log, err, fmt, arg1, arg2, arg3) | ||
|
||
#define ngx_log_debug4(level, log, err, fmt, arg1, arg2, arg3, arg4) \ | ||
- if ((log)->log_level & level) \ | ||
+ if (ngx_http_lua_kong_get_dynamic_log_level((log)->log_level) & level) \ | ||
ngx_log_debug_core(log, err, fmt, arg1, arg2, arg3, arg4) | ||
|
||
#define ngx_log_debug5(level, log, err, fmt, arg1, arg2, arg3, arg4, arg5) \ | ||
- if ((log)->log_level & level) \ | ||
+ if (ngx_http_lua_kong_get_dynamic_log_level((log)->log_level) & level) \ | ||
ngx_log_debug_core(log, err, fmt, arg1, arg2, arg3, arg4, arg5) | ||
|
||
#define ngx_log_debug6(level, log, err, fmt, \ | ||
arg1, arg2, arg3, arg4, arg5, arg6) \ | ||
- if ((log)->log_level & level) \ | ||
+ if (ngx_http_lua_kong_get_dynamic_log_level((log)->log_level) & level) \ | ||
ngx_log_debug_core(log, err, fmt, arg1, arg2, arg3, arg4, arg5, arg6) | ||
|
||
#define ngx_log_debug7(level, log, err, fmt, \ | ||
arg1, arg2, arg3, arg4, arg5, arg6, arg7) \ | ||
- if ((log)->log_level & level) \ | ||
+ if (ngx_http_lua_kong_get_dynamic_log_level((log)->log_level) & level) \ | ||
ngx_log_debug_core(log, err, fmt, \ | ||
arg1, arg2, arg3, arg4, arg5, arg6, arg7) | ||
|
||
#define ngx_log_debug8(level, log, err, fmt, \ | ||
arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) \ | ||
- if ((log)->log_level & level) \ | ||
+ if (ngx_http_lua_kong_get_dynamic_log_level((log)->log_level) & level) \ | ||
ngx_log_debug_core(log, err, fmt, \ | ||
arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) | ||
|
29 changes: 29 additions & 0 deletions
29
build/openresty/patches/ngx_lua-0.10.21_07-dynamic_log_level.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
diff --git a/bundle/ngx_lua-0.10.21/src/ngx_http_lua_log.c b/bundle/ngx_lua-0.10.21/src/ngx_http_lua_log.c | ||
index 43ab820..d18fd05 100644 | ||
--- a/bundle/ngx_lua-0.10.21/src/ngx_http_lua_log.c | ||
+++ b/bundle/ngx_lua-0.10.21/src/ngx_http_lua_log.c | ||
@@ -101,7 +101,11 @@ log_wrapper(ngx_log_t *log, const char *ident, ngx_uint_t level, | ||
const char *msg; | ||
lua_Debug ar; | ||
|
||
+#if (NGX_HTTP_LUA_KONG) | ||
+ if (level > ngx_http_lua_kong_get_dynamic_log_level(log->log_level)) { | ||
+#else | ||
if (level > log->log_level) { | ||
+#endif | ||
return 0; | ||
} | ||
|
||
@@ -427,7 +431,12 @@ ngx_http_lua_ffi_errlog_get_sys_filter_level(ngx_http_request_t *r) | ||
log = ngx_cycle->log; | ||
} | ||
|
||
+#if (NGX_HTTP_LUA_KONG) | ||
+ log_level = ngx_http_lua_kong_get_dynamic_log_level(log->log_level); | ||
+#else | ||
log_level = log->log_level; | ||
+#endif | ||
+ | ||
if (log_level == NGX_LOG_DEBUG_ALL) { | ||
log_level = NGX_LOG_DEBUG; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.