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

View File

@@ -81,7 +81,7 @@ int Simulator::start(int argc, char *argv[])
int ret = 0;
_instance = new Simulator();
if (_instance) {
PX4_INFO("Simulator started\n");
PX4_INFO("Simulator started");
drv_led_start();
if (argv[2][1] == 's') {
#ifndef __PX4_QURT
@@ -92,7 +92,7 @@ int Simulator::start(int argc, char *argv[])
}
}
else {
PX4_WARN("Simulator creation failed\n");
PX4_WARN("Simulator creation failed");
ret = 1;
}
return ret;
@@ -150,7 +150,7 @@ void Simulator::publishSensorsCombined() {
gyro.timestamp = time_last;
mag.timestamp = time_last;
// publish the sensor values
//printf("Publishing SensorsCombined\n");
//PX4_DEBUG("Publishing SensorsCombined\n");
orb_publish(ORB_ID(sensor_combined), _sensor_combined_pub, &sensors);
orb_publish(ORB_ID(sensor_baro), _baro_pub, &baro);
orb_publish(ORB_ID(sensor_accel), _accel_pub, &baro);
@@ -225,14 +225,14 @@ bool static _led_state[2] = { false , false };
__EXPORT void led_init()
{
PX4_DBG("LED_INIT\n");
PX4_DEBUG("LED_INIT");
}
__EXPORT void led_on(int led)
{
if (led == 1 || led == 0)
{
PX4_DBG("LED%d_ON", led);
PX4_DEBUG("LED%d_ON", led);
_led_state[led] = true;
}
}
@@ -241,7 +241,7 @@ __EXPORT void led_off(int led)
{
if (led == 1 || led == 0)
{
PX4_DBG("LED%d_OFF", led);
PX4_DEBUG("LED%d_OFF", led);
_led_state[led] = false;
}
}
@@ -251,7 +251,7 @@ __EXPORT void led_toggle(int led)
if (led == 1 || led == 0)
{
_led_state[led] = !_led_state[led];
PX4_DBG("LED%d_TOGGLE: %s\n", led, _led_state[led] ? "ON" : "OFF");
PX4_DEBUG("LED%d_TOGGLE: %s", led, _led_state[led] ? "ON" : "OFF");
}
}