Skip to content
Closed
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
2 changes: 2 additions & 0 deletions include/rdk_logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,8 @@ typedef enum
{
RDKLOG_FORMAT_PLAINTEXT = 0, /** format_plaintext */
RDKLOG_FORMAT_WITH_TS, /** format_with_ts */
RDKLOG_FORMAT_WITH_TID, /** format_with_tid */
RDKLOG_FORMAT_WITH_TS_TID, /** format_with_ts_tid */
RDKLOG_FORMAT_DETAIL_WITH_TS, /** format_detail_with_ts */
RDKLOG_FORMAT_DETAIL_WITHOUT_TS /** format_detail_without_ts */
} rdk_LogFormat;
Expand Down
11 changes: 7 additions & 4 deletions log4crc
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
<log4c>

<config>
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

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

Setting bufsize to 0 in the log4c configuration means the buffer will be dynamically allocated on demand. While this aligns with the removal of LOG4C_MSG_BUFFER_SIZE truncation logic, it may have performance implications since buffer allocation/reallocation will occur for every log message. Consider documenting this change and its performance implications, especially for high-frequency logging scenarios.

Suggested change
<config>
<config>
<!--
NOTE: bufsize=0 causes log4c to dynamically allocate the message buffer
for each log entry instead of using a fixed-size buffer. This avoids
LOG4C_MSG_BUFFER_SIZE-based truncation but can introduce additional
allocation overhead, especially under high-frequency logging.
This trade-off is intentional; adjust bufsize to a non-zero value
if fixed-size buffering and reduced allocation cost are preferred.
-->

Copilot uses AI. Check for mistakes.
<bufsize>1024</bufsize>
<bufsize>0</bufsize>
Copy link

Copilot AI Feb 22, 2026

Choose a reason for hiding this comment

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

Setting bufsize to 0 in the log4c configuration means the buffer will dynamically grow as needed via realloc. However, there's a critical bug in the realloc implementation at src/rdk_debug_priv.c:778 where the return value is not checked for NULL. This configuration change makes the memory allocation failure path more likely to be hit with large log messages. The realloc bug must be fixed before this configuration change can be safely deployed.

Suggested change
<bufsize>0</bufsize>
<bufsize>2048</bufsize>

Copilot uses AI. Check for mistakes.
<debug level="0"/>
<nocleanup>0</nocleanup>
<reread>0</reread>
</config>

<layout name="rdk_plaintext" type="format_plaintext"/>
<layout name="rdk_with_ts" type="format_with_ts"/>
<layout name="rdk_with_tid" type="format_with_tid"/>
<layout name="rdk_with_ts_tid" type="format_with_ts_tid"/>
<layout name="rdk_detail_with_ts" type="format_detail_with_ts"/>
<layout name="rdk_detail_without_ts" type="format_detail_without_ts"/>

<appender name="rdk_console" type="to_console" layout="rdk_detail_with_ts"/>
<appender name="rdk_syslog" type="to_syslog" layout="rdk_detail_without_ts"/>
<appender name="rdk_console" type="to_console" layout="rdk_detail_without_ts"/>
<appender name="rdk_syslog" type="to_syslog" layout="rdk_with_tid"/>
<appender name="rdk_journal" type="to_journal" layout="rdk_plaintext"/>
<appender name="rdk_printf" type="to_console" layout="rdk_detail_with_ts"/>

Comment on lines +17 to 21
Copy link

Copilot AI Feb 22, 2026

Choose a reason for hiding this comment

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

These changes modify default logging behavior (root category now uses rdk_console instead of rdk_syslog; console/syslog layouts changed). This is potentially breaking for consumers relying on previous defaults, and it isn’t mentioned in the PR description. Please confirm it’s intended and document the behavior change (or preserve existing defaults).

Copilot uses AI. Check for mistakes.
<category name="LOG.RDK" priority="warning" appender="rdk_syslog"/>
<category name="LOG.RDK" priority="warning" appender="rdk_console"/>
</log4c>
24 changes: 16 additions & 8 deletions src/rdk_debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,12 @@ void rdk_logger_msg_printf(rdk_LogLevel level, const char *module, const char *f
{
va_list args;

va_start(args, format);
rdk_dbg_priv_log_msg(level, module, format, args);
va_end(args);
if ((!format) && (!module))
{
va_start(args, format);
rdk_dbg_priv_log_msg(level, module, format, args);
va_end(args);
}
Comment on lines +49 to +54
Copy link

Copilot AI Feb 22, 2026

Choose a reason for hiding this comment

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

The null pointer check logic is inverted. The condition uses AND (&&) when it should use OR (||). Currently, the function only logs when BOTH format AND module are NULL, which is incorrect. It should log when EITHER format OR module is NOT NULL. Change the condition to if (format || module) to correctly allow logging when at least one of these parameters is valid.

Copilot uses AI. Check for mistakes.
}

/**
Expand All @@ -63,19 +66,24 @@ void rdk_dbg_MsgRaw(rdk_LogLevel level, const char *module, const char *format,
{
va_list args;

va_start(args, format);
rdk_dbg_priv_log_msg(level, module, format, args);
va_end(args);
if ((!format) && (!module))
{
va_start(args, format);
rdk_dbg_priv_log_msg(level, module, format, args);
va_end(args);
}
Comment on lines +69 to +74
Copy link

Copilot AI Feb 22, 2026

Choose a reason for hiding this comment

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

The null pointer check logic is inverted. The condition uses AND (&&) when it should use OR (||). Currently, the function only logs when BOTH format AND module are NULL, which is incorrect. It should log when EITHER format OR module is NOT NULL. Change the condition to if (format || module) to correctly allow logging when at least one of these parameters is valid.

Copilot uses AI. Check for mistakes.
}

void rdk_logger_msg_vsprintf(rdk_LogLevel level, const char *module, const char *format, va_list args)
{
rdk_dbg_priv_log_msg(level, module, format, args);
if ((!format) && (!module))
rdk_dbg_priv_log_msg(level, module, format, args);
Comment on lines +79 to +80
Copy link

Copilot AI Feb 22, 2026

Choose a reason for hiding this comment

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

The null pointer check logic is inverted. The condition uses AND (&&) when it should use OR (||). Currently, the function only logs when BOTH format AND module are NULL, which is incorrect. It should log when EITHER format OR module is NOT NULL. Change the condition to if (format || module) to correctly allow logging when at least one of these parameters is valid.

Copilot uses AI. Check for mistakes.
}

void rdk_dbg_MsgRaw1(rdk_LogLevel level, const char *module, const char *format, va_list args)
{
rdk_dbg_priv_log_msg(level, module, format, args);
if ((!format) && (!module))
rdk_dbg_priv_log_msg(level, module, format, args);
Comment on lines +85 to +86
Copy link

Copilot AI Feb 22, 2026

Choose a reason for hiding this comment

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

The null pointer check logic is inverted. The condition uses AND (&&) when it should use OR (||). Currently, the function only logs when BOTH format AND module are NULL, which is incorrect. It should log when EITHER format OR module is NOT NULL. Change the condition to if (format || module) to correctly allow logging when at least one of these parameters is valid.

Copilot uses AI. Check for mistakes.
}

/**
Expand Down
Loading
Loading