Skip to content
21 changes: 10 additions & 11 deletions docs/API_DOCUMENTATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -328,19 +328,19 @@ The `rdklogctrl` command-line utility allows runtime modification of log levels:

```bash
# Set log level for a module
rdklogctrl <app_name> <module_name> <log_level>
rdklogctrl <pid> <module_name> <log_level>

# Examples
rdklogctrl myapp LOG.RDK.NETWORK DEBUG
rdklogctrl receiver LOG.RDK.AUDIO INFO
rdklogctrl player LOG.RDK.VIDEO ERROR
rdklogctrl "$(pidof -s myapp)" LOG.RDK.NETWORK DEBUG
rdklogctrl "$(pidof -s receiver)" LOG.RDK.AUDIO INFO
rdklogctrl "$(pidof -s player)" LOG.RDK.VIDEO ERROR

# Disable specific log level (using ~ prefix)
rdklogctrl myapp LOG.RDK.NETWORK ~DEBUG
rdklogctrl "$(pidof -s myapp)" LOG.RDK.NETWORK ~DEBUG
```

**Parameters**:
- `app_name`: Process name as shown by `ps` command
- `pid`: Process ID of the target application; `rdklogctrl` resolves its name from `/proc`
- `module_name`: Module name (must match debug.ini format)
- `log_level`: FATAL, ERROR, WARN, NOTICE, INFO, DEBUG, TRACE, NONE

Expand Down Expand Up @@ -401,19 +401,19 @@ For backward compatibility with legacy RDK components:

**Usage**:
```bash
rdklogctrl <app_name> <module_name> <log_level>
rdklogctrl <pid> <module_name> <log_level>
```

**Examples**:
```bash
# Enable debug logging for network module
rdklogctrl receiver LOG.RDK.NETWORK DEBUG
rdklogctrl "$(pidof -s receiver)" LOG.RDK.NETWORK DEBUG

# Disable all logging for test module
rdklogctrl myapp LOG.RDK.TEST NONE
rdklogctrl "$(pidof -s myapp)" LOG.RDK.TEST NONE

# Turn off only error logs (keep others)
rdklogctrl player LOG.RDK.AUDIO ~ERROR
rdklogctrl "$(pidof -s player)" LOG.RDK.AUDIO ~ERROR
```

### rdklogmilestone - Milestone Utility
Expand Down Expand Up @@ -762,4 +762,3 @@ int main() {
---

**Note**: This documentation covers RDK Logger API version as implemented in the current codebase. For the most up-to-date information, refer to the source code and header files.

17 changes: 10 additions & 7 deletions docs/QUICK_REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,18 @@ LOG.RDK.TEST=NONE
### rdklogctrl Command
```bash
# Set log level for module
rdklogctrl <process_name> <module_name> <level>
rdklogctrl <pid> <module_name> <level>

# Example for PID 1122
rdklogctrl 1122 LOG.RDK.RTMESS DEBUG

# Examples
rdklogctrl myapp LOG.RDK.NETWORK DEBUG
rdklogctrl receiver LOG.RDK.AUDIO INFO
rdklogctrl player LOG.RDK.VIDEO ERROR
rdklogctrl "$(pidof -s myapp)" LOG.RDK.NETWORK DEBUG
rdklogctrl "$(pidof -s receiver)" LOG.RDK.AUDIO INFO
rdklogctrl "$(pidof -s player)" LOG.RDK.VIDEO ERROR

# Disable specific level (~ prefix)
rdklogctrl myapp LOG.RDK.NETWORK ~DEBUG
rdklogctrl "$(pidof -s myapp)" LOG.RDK.NETWORK ~DEBUG

# Available levels
FATAL ERROR WARN NOTICE INFO DEBUG TRACE NONE
Expand Down Expand Up @@ -307,7 +310,7 @@ int main() {
APP_PID=$!

# Change log level
rdklogctrl myapp LOG.RDK.TEST DEBUG
rdklogctrl "$APP_PID" LOG.RDK.TEST DEBUG

# Check if change took effect (application should show more logs)

Expand All @@ -333,4 +336,4 @@ kill $APP_PID
- `rdklogctrl` - Runtime log control utility
- `rdklogmilestone` - Milestone logging utility

This quick reference provides the most commonly needed information for day-to-day RDK Logger usage.
This quick reference provides the most commonly needed information for day-to-day RDK Logger usage.
79 changes: 38 additions & 41 deletions docs/README.md

Large diffs are not rendered by default.

23 changes: 10 additions & 13 deletions docs/TROUBLESHOOTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,18 +135,18 @@ find /etc -name "*log4c*" 2>/dev/null
**Problem:** Changes don't take effect
```bash
# Command appears to work but no change
rdklogctrl myapp LOG.RDK.NETWORK DEBUG
rdklogctrl "$(pidof -s myapp)" LOG.RDK.NETWORK DEBUG
```

**Debugging:**

**Step 1: Verify process name**
```bash
# Check exact process name
ps aux | grep myapp
pgrep -o myapp

# Use exact name from ps output
rdklogctrl "myapp_process_name" LOG.RDK.NETWORK DEBUG
rdklogctrl "$(pidof -s myapp)" LOG.RDK.NETWORK DEBUG
```

**Step 2: Check process accessibility**
Expand All @@ -155,13 +155,13 @@ rdklogctrl "myapp_process_name" LOG.RDK.NETWORK DEBUG
ps -ef | grep myapp

# Check if process accepts socket connections
netstat -tlnp | grep :12035
ss -xlp | grep '/tmp/.logger_'
```

**Step 3: Test with simple module**
```bash
# Try with a known module first
rdklogctrl myapp LOG.RDK.DEFAULT INFO
rdklogctrl "$(pidof -s myapp)" LOG.RDK.DEFAULT INFO
```

#### Issue: Dynamic logging not persistent
Expand Down Expand Up @@ -486,14 +486,11 @@ void debug_config_loading() {

#### Network Debugging for rdklogctrl
```bash
# Check if dynamic logger port is listening
netstat -tlnp | grep :12035
# List per-process dynamic logger sockets
ss -xlpn | grep '/tmp/.logger_'

# Test socket connection
telnet localhost 12035

# Monitor network traffic
tcpdump -i lo port 12035
# Verify socket ownership and permissions
ls -l /tmp/.logger_<process_name>.<pid>`
```

### Quick Reference Checklist
Expand All @@ -511,4 +508,4 @@ When troubleshooting RDK Logger issues:
9. **✓ Use debugging tools (valgrind, gdb, strace)**
10. **✓ Enable log4c debugging if needed**

This troubleshooting guide should help resolve most common issues with RDK Logger implementation and usage.
This troubleshooting guide should help resolve most common issues with RDK Logger implementation and usage.
8 changes: 8 additions & 0 deletions include/rdk_logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,14 @@ bool rdk_logger_is_logLevel_enabled(const char *module, rdk_LogLevel level);
*/
bool rdk_logger_set_logLevel(const char *module, rdk_LogLevel logLevel);

/**
* @brief Get the effective log level for a module.
* @param module Module name.
* @param logLevel Receives the effective log level on success.
* @return TRUE if the level was retrieved, FALSE for invalid arguments or an unknown level.
*/
bool rdk_logger_get_logLevel(const char *module, rdk_LogLevel *logLevel);

/**
* @brief Log a message for onboard logging.
* @param module Module name.
Expand Down
5 changes: 3 additions & 2 deletions src/include/rdk_debug_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ void rdk_dbg_priv_init(void);
rdk_Error rdk_dbg_priv_config(const char *pConfigFile);
void rdk_dbg_priv_deinit(void);
rdk_Error rdk_dbg_priv_ext_init (const rdk_logger_ext_config_t* config);
void rdk_dbg_priv_log_msg(rdk_LogLevel level, const char *module_name, const char* format, va_list args);
bool rdk_dbg_priv_log_reconfig(const char *pModuleName, rdk_LogLevel level);
void rdk_dbg_priv_log(rdk_LogLevel level, const char *module_name, const char* format, va_list args);
bool rdk_dbg_priv_set_level(const char *pModuleName, rdk_LogLevel level);
bool rdk_dbg_priv_get_level(const char *pModuleName, rdk_LogLevel *level);

#ifdef __cplusplus
}
Expand Down
11 changes: 6 additions & 5 deletions src/include/rdk_dynamic_logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@
#include <stdint.h>
#include <rdk_logger.h>

#define RDK_DYNAMIC_LOG_PACKET_MAX 128
#define RDK_DYNAMIC_LOG_APP_NAME_MAX 120
#define RDK_DYNAMIC_LOG_APP_NAME_MAX 64
#define RDK_DYNAMIC_LOG_COMPONENT_NAME_MAX 64

#define RDK_DYNAMIC_SOCKET_PATH_PREFIX "/tmp/.logger"
Comment thread
dshett549 marked this conversation as resolved.
Resolved
#define RDK_DYNAMIC_LOG_SIGNATURE "COMC"
#define RDK_DYNAMIC_LOG_SIGNATURE_LEN 5

typedef struct {
// Adjusting sizes for legacy UDP datagram limits
uint8_t signature[4];
uint8_t message_length;
uint8_t signature[RDK_DYNAMIC_LOG_SIGNATURE_LEN];
uint8_t log_level;
char app_name[RDK_DYNAMIC_LOG_APP_NAME_MAX + 1];
char component_name[RDK_DYNAMIC_LOG_COMPONENT_NAME_MAX + 1];
Expand Down
24 changes: 18 additions & 6 deletions src/rdk_debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void rdk_logger_msg_printf(rdk_LogLevel level, const char *module, const char *f
if ((format) && (module))
{
va_start(args, format);
rdk_dbg_priv_log_msg(level, module, format, args);
rdk_dbg_priv_log(level, module, format, args);
va_end(args);
}
}
Expand All @@ -69,21 +69,21 @@ void rdk_dbg_MsgRaw(rdk_LogLevel level, const char *module, const char *format,
if ((format) && (module))
{
va_start(args, format);
rdk_dbg_priv_log_msg(level, module, format, args);
rdk_dbg_priv_log(level, module, format, args);
va_end(args);
}
}

void rdk_logger_msg_vsprintf(rdk_LogLevel level, const char *module, const char *format, va_list args)
{
if ((format) && (module))
rdk_dbg_priv_log_msg(level, module, format, args);
rdk_dbg_priv_log(level, module, format, args);
}

void rdk_dbg_MsgRaw1(rdk_LogLevel level, const char *module, const char *format, va_list args)
{
if ((format) && (module))
rdk_dbg_priv_log_msg(level, module, format, args);
rdk_dbg_priv_log(level, module, format, args);
}

/**
Expand All @@ -97,11 +97,23 @@ void rdk_dbg_MsgRaw1(rdk_LogLevel level, const char *module, const char *format,
bool rdk_logger_set_logLevel(const char *module, rdk_LogLevel logLevel)
{
if (module)
return rdk_dbg_priv_log_reconfig(module, logLevel);
return rdk_dbg_priv_set_level(module, logLevel);
else
return false;
}

/**
* @brief Get the effective log level for a module.
* @param module Module name.
* @param logLevel Receives the effective log level on success.
* @return TRUE if the level was retrieved, FALSE for invalid arguments or an unknown level.
*/
bool rdk_logger_get_logLevel(const char *module, rdk_LogLevel *logLevel)
{
return rdk_dbg_priv_get_level(module, logLevel);
}


/**
* @brief Enable or disable a log level for a module.
* @param module Module name.
Expand All @@ -113,7 +125,7 @@ bool rdk_logger_enable_logLevel(const char *module, rdk_LogLevel logLevel, rdk_l
{
(void) enableLogLvl;
if (module)
return rdk_dbg_priv_log_reconfig(module, logLevel);
return rdk_dbg_priv_set_level(module, logLevel);
else
return false;
}
Expand Down
45 changes: 43 additions & 2 deletions src/rdk_debug_priv.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,22 @@ static int rdk_logLevel_to_log4c_priority(rdk_LogLevel level)
return LOG4C_PRIORITY_UNKNOWN;
}

static rdk_LogLevel log4c_priority_to_rdk_logLevel (int level)
{
switch (level)
{
case LOG4C_PRIORITY_FATAL: return RDK_LOG_FATAL;
case LOG4C_PRIORITY_ERROR: return RDK_LOG_ERROR;
case LOG4C_PRIORITY_WARN: return RDK_LOG_WARN;
case LOG4C_PRIORITY_NOTICE: return RDK_LOG_NOTICE;
case LOG4C_PRIORITY_INFO: return RDK_LOG_INFO;
case LOG4C_PRIORITY_DEBUG: return RDK_LOG_DEBUG;
case LOG4C_PRIORITY_TRACE: return RDK_LOG_TRACE;
default:
return RDK_LOG_NONE;
}
}

#if defined(HAVE_SYSTEMD) || defined(HAVE_SYSLOG_H)
static int get_syslog_priority(int log4c_pr)
{
Expand Down Expand Up @@ -610,7 +626,7 @@ bool rdk_logger_is_logLevel_enabled(const char *module, rdk_LogLevel level)
return isEnabled;
}

void rdk_dbg_priv_log_msg(rdk_LogLevel level, const char *module_name, const char* format, va_list args)
void rdk_dbg_priv_log(rdk_LogLevel level, const char *module_name, const char* format, va_list args)
{
log4c_category_t* cat = NULL;
int prio = 0;
Expand Down Expand Up @@ -658,7 +674,7 @@ void rdk_dbg_priv_log_msg(rdk_LogLevel level, const char *module_name, const cha
}


bool rdk_dbg_priv_log_reconfig(const char *pModuleName, rdk_LogLevel logLevel)
bool rdk_dbg_priv_set_level(const char *pModuleName, rdk_LogLevel logLevel)
{
bool ret = true;
log4c_category_t* cat = NULL;
Expand All @@ -684,6 +700,31 @@ bool rdk_dbg_priv_log_reconfig(const char *pModuleName, rdk_LogLevel logLevel)
return ret;
}

bool rdk_dbg_priv_get_level(const char *pModuleName, rdk_LogLevel *level)
{
log4c_category_t* cat = NULL;
int priority = gRootPriority;

if (pModuleName == NULL || pModuleName[0] == '\0' || level == NULL)
return false;

pthread_mutex_lock(&gLoggingMutex);
cat = log4c_category_get(pModuleName);
if (cat == NULL) {
pthread_mutex_unlock(&gLoggingMutex);
return false;
}

priority = log4c_category_get_priority(cat);
if (priority == LOG4C_PRIORITY_NOTSET)
priority = gRootPriority;
Comment thread
Copilot marked this conversation as resolved.
Resolved

*level = log4c_priority_to_rdk_logLevel(priority);

pthread_mutex_unlock(&gLoggingMutex);
return true;
}

#define COMCAST_DATAED_BUFF_SIZE 40
/****************************************************************
* Wrapper function to retrieve module name
Expand Down
Loading
Loading