POSIX: Improved logging

The warnx and warn calls map to PX4_WARN.
Calls to errx or err genrtate a compile error.

The px4_log.h file implements a new log format:

For DEBUG and INFO:
<level> <msg>

For ERROR and WARN:
<level> <msg> (file filepath line linenum)

The verbosity can be changed by setting the macro to use
either linux_log or linux_log_verbose in px4_log.h

Signed-off-by: Mark Charlebois <charlebm@gmail.com>
This commit is contained in:
Mark Charlebois
2015-05-19 09:19:24 -07:00
parent 791d780bb8
commit ffdc9d629c
17 changed files with 161 additions and 120 deletions
@@ -83,9 +83,9 @@ static void *entry_adapter ( void *ptr )
data->entry(data->argc, data->argv);
free(ptr);
PX4_DBG("Before px4_task_exit");
PX4_DEBUG("Before px4_task_exit");
px4_task_exit(0);
PX4_DBG("After px4_task_exit");
PX4_DEBUG("After px4_task_exit");
return NULL;
}
@@ -231,7 +231,7 @@ void px4_task_exit(int ret)
PX4_ERR("px4_task_exit: self task not found!");
}
else {
PX4_DBG("px4_task_exit: %s", taskmap[i].name.c_str());
PX4_DEBUG("px4_task_exit: %s", taskmap[i].name.c_str());
}
pthread_exit((void *)(unsigned long)ret);
@@ -241,7 +241,7 @@ int px4_task_kill(px4_task_t id, int sig)
{
int rv = 0;
pthread_t pid;
PX4_DBG("Called px4_task_kill %d", sig);
PX4_DEBUG("Called px4_task_kill %d", sig);
if (id < PX4_MAX_TASKS && taskmap[id].pid != 0)
pid = taskmap[id].pid;
@@ -271,3 +271,18 @@ void px4_show_tasks()
PX4_INFO(" No running tasks");
}
__BEGIN_DECLS
const char *getprogname()
{
pthread_t pid = pthread_self();
for (int i=0; i<PX4_MAX_TASKS; i++)
{
if (taskmap[i].isused && taskmap[i].pid == pid)
{
return taskmap[i].name.c_str();
}
}
return "Unknown App";
}
__END_DECLS