Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 19 additions & 9 deletions src/rdk_debug_priv.c
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,11 @@ rdk_Error rdk_logger_parse_config( const char * path)

void rdk_dbg_priv_init(void)
{
static bool isInited = false;

if(isInited)
return;

///> These must be set before calling log4c_init so that the log4crc file
///> will configure them
(void) log4c_layout_type_set(&log4c_layout_type_rdk_plaintext);
Expand All @@ -329,14 +334,19 @@ void rdk_dbg_priv_init(void)
(void) log4c_appender_type_set(&log4c_appender_type_to_syslog);
(void) log4c_appender_type_set(&log4c_appender_type_to_journal);

if (0 != log4c_init())
{
fprintf(stderr, "log4c_init() failed?!\n");
}
else
{
/* Register this for legacy Components */
log4c_layout_t* legacy = log4c_layout_get("comcast_dated");
if (NULL != legacy)
(void) log4c_layout_set_type(legacy, &log4c_layout_type_comcast_dated);

if (log4c_init())
fprintf(stderr, "log4c_init() failed?!");

/* Register this for legacy Components */
log4c_layout_t* legacy = log4c_layout_get("comcast_dated");
if (NULL != legacy)
(void) log4c_layout_set_type(legacy, &log4c_layout_type_comcast_dated);
isInited = true;
}
Comment thread
karuna2git marked this conversation as resolved.

return;
}
Expand All @@ -353,7 +363,7 @@ rdk_Error rdk_dbg_priv_config(const char* debugConfigFile)
/* Get the root category */
if (!gRootCat)
{
fprintf(stderr, "RDK Root Category Creation failed?!");
fprintf(stderr, "RDK Root Category Creation failed?!\n");
}
}
/* Read the config file & populate pre-configured log levels */
Expand All @@ -364,7 +374,7 @@ rdk_Error rdk_dbg_priv_config(const char* debugConfigFile)
}
else
{
fprintf(stderr, "Invalid conf file!");
fprintf(stderr, "Invalid conf file!\n");
ret = RDK_FAILURE;
}

Expand Down
9 changes: 1 addition & 8 deletions src/rdk_logger_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,6 @@ static pthread_mutex_t gInitMutex = PTHREAD_MUTEX_INITIALIZER;

bool isLogInited = false;

static void __attribute__((constructor)) _rdk_logger_init (void)
{
/* Perform Logger Internal Init */
rdk_dbg_priv_init();

return;
}

/**
* @brief Initialize the logger. Sets up the environment variable storage by parsing
* debug configuration file then Initialize the debug support to the underlying platform.
Expand All @@ -73,6 +65,7 @@ rdk_Error rdk_logger_init(const char* debugConfigFile)
debugConfigFile = DEBUG_CONF_FILE;
}

rdk_dbg_priv_init();
/* Perform Logger Internal Init */
ret = rdk_dbg_priv_config(debugConfigFile);
Comment thread
karuna2git marked this conversation as resolved.

Expand Down
2 changes: 1 addition & 1 deletion test/rdk_logger_cpu_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ int testLogging()

getCPUStat(&cpu_after);
PrintCPUMetric(cpu_before, cpu_after, "Ext Init");
usleep(1000);
usleep(10000);

// Test 1: Print DEBUG where DEBUG is not enabled.
// CPU taken to drop the log message
Expand Down