Skip to content

Commit

Permalink
Add a couple comments around log ginit
Browse files Browse the repository at this point in the history
Signed-off-by: Bob Weinand <[email protected]>
  • Loading branch information
bwoebi committed Feb 1, 2024
1 parent 27dfb45 commit e2ddbee
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion ext/configuration.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ static void dd_ini_env_to_ini_name(const zai_str env_name, zai_config_name *ini_
bool ddtrace_config_minit(int module_number) {
if (!zai_config_minit(config_entries, (sizeof config_entries / sizeof *config_entries), dd_ini_env_to_ini_name,
module_number)) {
ddtrace_log_ginit();
LOG(Error, "Unable to load configuration; likely due to json symbols failing to resolve.");
return false;
}
Expand All @@ -141,7 +142,7 @@ bool ddtrace_config_minit(int module_number) {
// arduous way of accessing the decoded_value directly from zai_config_memoized_entries.
zai_config_first_time_rinit();

ddtrace_alter_dd_trace_debug(NULL, &zai_config_memoized_entries[DDTRACE_CONFIG_DD_TRACE_DEBUG].decoded_value);
ddtrace_log_ginit();
return true;
}

Expand Down
3 changes: 2 additions & 1 deletion ext/ddtrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,6 @@ static void dd_disable_if_incompatible_sapi_detected(void) {
static PHP_MINIT_FUNCTION(ddtrace) {
UNUSED(type);

ddtrace_log_init();

zai_hook_minit();
zai_uhook_minit(module_number);
Expand All @@ -921,6 +920,8 @@ static PHP_MINIT_FUNCTION(ddtrace) {
}

// config initialization needs to be at the top
// This also initialiyzed logging, so no logs may be emitted before this.
ddtrace_log_init();
if (!ddtrace_config_minit(module_number)) {
return FAILURE;
}
Expand Down
1 change: 1 addition & 0 deletions ext/logging.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ static void dd_log_set_level(bool debug) {
}
}

// We need to ensure that logging is initialized (i.e. set) at least once per thread.
void ddtrace_log_ginit(void) {
dd_log_set_level(get_global_DD_TRACE_DEBUG());
}
Expand Down

0 comments on commit e2ddbee

Please sign in to comment.