Skip to content

RDKEMW-14300 : Move the log4c init to logger init#55

Merged
karuna2git merged 1 commit intodevelopfrom
topic/reviewLog4c
Feb 24, 2026
Merged

RDKEMW-14300 : Move the log4c init to logger init#55
karuna2git merged 1 commit intodevelopfrom
topic/reviewLog4c

Conversation

@karuna2git
Copy link
Copy Markdown
Contributor

Reason for change: Move the log4c init to logger init
Test Procedure: Verify logging
Risks: Medium

@karuna2git karuna2git requested a review from a team as a code owner February 24, 2026 20:13
Copilot AI review requested due to automatic review settings February 24, 2026 20:13
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the RDK logger initialization by moving log4c initialization from an automatically executed constructor function to an explicit call within rdk_logger_init(). This change makes the initialization sequence more predictable and controllable. Additionally, it improves error message formatting by adding missing newline characters to stderr fprintf statements, and adjusts test timing to better capture CPU metrics.

Changes:

  • Removed __attribute__((constructor)) function that automatically initialized log4c at program startup
  • Moved rdk_dbg_priv_init() call to be explicitly invoked within rdk_logger_init()
  • Added missing newline characters to three fprintf error messages for consistency

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/rdk_logger_init.c Removed constructor function and added explicit call to rdk_dbg_priv_init() within rdk_logger_init()
src/rdk_debug_priv.c Added newline characters to error messages for consistent formatting
test/rdk_logger_cpu_test.c Increased usleep delay from 1ms to 10ms for more stable CPU metric collection

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/rdk_logger_init.c
Reason for change: Move the log4c init to logger init
Test Procedure: Verify logging
Risks: Medium
Signed-off-by: Karunakaran A <karunakaran_amirthalingam@cable.comcast.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/rdk_logger_init.c
Comment on lines 57 to 71
rdk_Error rdk_logger_init(const char* debugConfigFile)
{
rdk_Error ret = RDK_SUCCESS;
pthread_mutex_lock(&gInitMutex);
if (!isLogInited)
{
if (NULL == debugConfigFile)
{
debugConfigFile = DEBUG_CONF_FILE;
}

rdk_dbg_priv_init();
/* Perform Logger Internal Init */
ret = rdk_dbg_priv_config(debugConfigFile);

Copy link

Copilot AI Feb 24, 2026

Choose a reason for hiding this comment

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

Removing the shared-library constructor means log4c/rdk internal initialization now only happens if callers explicitly invoke rdk_logger_init (or RDK_LOGGER_INIT). Any existing consumers that call rdk_logger_msg_printf/rdk_logger_is_logLevel_enabled without first initializing will now run log4c APIs before log4c_init(), which is a behavior change and can break logging at runtime. Consider keeping a safe lazy-init path (e.g., ensure rdk_dbg_priv_init runs before any log4c usage) or clearly enforcing/validating initialization and returning an error when logging is used pre-init.

Copilot uses AI. Check for mistakes.
Comment thread src/rdk_debug_priv.c
@karuna2git karuna2git merged commit b9d5106 into develop Feb 24, 2026
14 checks passed
@karuna2git karuna2git deleted the topic/reviewLog4c branch February 24, 2026 22:30
@github-actions github-actions Bot locked and limited conversation to collaborators Feb 24, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants