Commit 4a2f9d25 authored by Wilson W.K. Thong's avatar Wilson W.K. Thong Committed by Wilson Thong

#220 enhance logging to show also thread name

parent 040957c1
...@@ -1032,6 +1032,19 @@ void logRecord_mt(const char *file, const char *func, int line, int comp, ...@@ -1032,6 +1032,19 @@ void logRecord_mt(const char *file, const char *func, int line, int comp,
if (len > MAX_LOG_TOTAL) len = MAX_LOG_TOTAL; if (len > MAX_LOG_TOTAL) len = MAX_LOG_TOTAL;
} }
if ( (g_log->flag & FLAG_THREAD) || (c->flag & FLAG_THREAD) ) {
#define THREAD_NAME_LEN 16
static char threadname[THREAD_NAME_LEN];
if (pthread_getname_np(pthread_self(), threadname, THREAD_NAME_LEN) != 0)
{
perror("pthread_getname_np : ");
} else {
len += snprintf(&log_buffer[len], MAX_LOG_TOTAL - len, "[%s]", threadname);
if (len > MAX_LOG_TOTAL) len = MAX_LOG_TOTAL;
}
#undef THREAD_NAME_LEN
}
if ( (g_log->flag & FLAG_FUNCT) || (c->flag & FLAG_FUNCT) ) { if ( (g_log->flag & FLAG_FUNCT) || (c->flag & FLAG_FUNCT) ) {
len += snprintf(&log_buffer[len], MAX_LOG_TOTAL - len, "[%s] ", len += snprintf(&log_buffer[len], MAX_LOG_TOTAL - len, "[%s] ",
func); func);
...@@ -1287,11 +1300,15 @@ int set_comp_log(int component, int level, int verbosity, int interval) ...@@ -1287,11 +1300,15 @@ int set_comp_log(int component, int level, int verbosity, int interval)
LOG_EMERG); LOG_EMERG);
DevCheck((interval > 0) && (interval <= 0xFF), interval, 0, 0xFF); DevCheck((interval > 0) && (interval <= 0xFF), interval, 0, 0xFF);
#if 0
if ((verbosity == LOG_NONE) || (verbosity == LOG_LOW) || if ((verbosity == LOG_NONE) || (verbosity == LOG_LOW) ||
(verbosity == LOG_MED) || (verbosity == LOG_FULL) || (verbosity == LOG_MED) || (verbosity == LOG_FULL) ||
(verbosity == LOG_HIGH)) { (verbosity == LOG_HIGH)) {
g_log->log_component[component].flag = verbosity; g_log->log_component[component].flag = verbosity;
} }
#else
g_log->log_component[component].flag = verbosity;
#endif
g_log->log_component[component].level = level; g_log->log_component[component].level = level;
g_log->log_component[component].interval = interval; g_log->log_component[component].interval = interval;
......
...@@ -1417,7 +1417,7 @@ int main( int argc, char **argv ) { ...@@ -1417,7 +1417,7 @@ int main( int argc, char **argv ) {
set_comp_log(HW, LOG_DEBUG, LOG_HIGH, 1); set_comp_log(HW, LOG_DEBUG, LOG_HIGH, 1);
set_comp_log(PHY, LOG_DEBUG, LOG_HIGH, 1); set_comp_log(PHY, LOG_DEBUG, LOG_HIGH, 1);
set_comp_log(MAC, LOG_INFO, LOG_HIGH, 1); set_comp_log(MAC, LOG_INFO, LOG_HIGH, 1);
set_comp_log(RLC, LOG_INFO, LOG_HIGH, 1); set_comp_log(RLC, LOG_INFO, LOG_HIGH | FLAG_THREAD, 1);
set_comp_log(PDCP, LOG_INFO, LOG_HIGH, 1); set_comp_log(PDCP, LOG_INFO, LOG_HIGH, 1);
set_comp_log(OTG, LOG_INFO, LOG_HIGH, 1); set_comp_log(OTG, LOG_INFO, LOG_HIGH, 1);
set_comp_log(RRC, LOG_INFO, LOG_HIGH, 1); set_comp_log(RRC, LOG_INFO, LOG_HIGH, 1);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment