Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(dynamic_log_level): not work for nginx debug log #69

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

chobits
Copy link
Contributor

@chobits chobits commented Sep 27, 2023

DESCRIPTION

When we use this api to modify log level to debug, nginx debug log does not output. The lua debug log works as expected.

CHANGELOG

  • 1. return NGX_LOG_DEBUG_ALL to nginx-log-patch, and returnn log_level number to ffi upper user
  • 2. add test case

ISSUE

fix KAG-2644

@CLAassistant
Copy link

CLAassistant commented Sep 27, 2023

CLA assistant check
All committers have signed the CLA.

@chobits chobits marked this pull request as draft September 27, 2023 07:44
@Kong Kong deleted a comment from CLAassistant Sep 27, 2023
@@ -63,6 +63,11 @@ ngx_http_lua_kong_ffi_set_dynamic_log_level(int log_level, int timeout)
return NGX_ERROR;
}

/* adhere to nginx conventions */
if (log_level == NGX_LOG_DEBUG) {
log_level = NGX_LOG_DEBUG_ALL;
Copy link
Contributor Author

@chobits chobits Sep 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For reviewers, we need to adhere nginx conventions here. like the nginx magic, note taht NGX_LOG_DEBUG_ALL is numerically greater than NGX_LOG_DEBUG. This numeric relationship is crucial for the functioning of all code segments that involve log->log_level comparison in Nginx.

// src/core/ngx_log.c

ngx_http_core_error_log
 -> ngx_log_set_log
   -> ngx_log_set_levels
     
static char *
ngx_log_set_levels(ngx_conf_t *cf, ngx_log_t *log)
{
+-- 52 lines: ngx_uint_t   i, n, d, found;----------------------------------------------------------------------------
    if (log->log_level == NGX_LOG_DEBUG) {
        log->log_level = NGX_LOG_DEBUG_ALL;
    }

    return NGX_CONF_OK;
}


if (log_level == NGX_LOG_DEBUG_ALL) {
log_level = NGX_LOG_DEBUG;
}
Copy link
Contributor Author

@chobits chobits Sep 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the caller using ffi call, we need to translate it from 0x7fff fff0 to log level number 0~8.

@chobits chobits marked this pull request as ready for review September 27, 2023 09:34
@chobits

This comment was marked as off-topic.

t/008-log.t Show resolved Hide resolved
@chobits
Copy link
Contributor Author

chobits commented Oct 12, 2023

Do not merge this PR until we have released 3.5. We should make sure that kong 3.5 is stable and reliable.

@chobits chobits force-pushed the fix/dynamic_log_level branch from 8e873a0 to 2b68038 Compare October 13, 2023 02:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants