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
+10
View File
@@ -65,6 +65,7 @@
#ifndef _SYSTEMLIB_ERR_H
#define _SYSTEMLIB_ERR_H
#include <px4_log.h>
#include <stdarg.h>
#include "visibility.h"
@@ -72,6 +73,14 @@ __BEGIN_DECLS
__EXPORT const char *getprogname(void);
#ifdef __PX4_POSIX
#define err(...) ERROR
#define errx(...) ERROR
#define warn(...) PX4_WARN(__VA_ARGS__)
#define warnx(...) PX4_WARN(__VA_ARGS__)
#else
__EXPORT void err(int eval, const char *fmt, ...) __attribute__((noreturn, format(printf, 2, 3)));
__EXPORT void verr(int eval, const char *fmt, va_list) __attribute__((noreturn, format(printf, 2, 0)));
__EXPORT void errc(int eval, int code, const char *fmt, ...) __attribute__((noreturn, format(printf, 3, 4)));
@@ -84,6 +93,7 @@ __EXPORT void warnc(int code, const char *fmt, ...) __attribute__((format(print
__EXPORT void vwarnc(int code, const char *fmt, va_list) __attribute__((format(printf, 2, 0)));
__EXPORT void warnx(const char *fmt, ...) __attribute__((format(printf, 1, 2)));
__EXPORT void vwarnx(const char *fmt, va_list) __attribute__((format(printf, 1, 0)));
#endif
__END_DECLS
+3 -2
View File
@@ -35,7 +35,7 @@
# System utility library
#
SRCS = err.c \
SRCS = \
perf_counter.c \
param/param.c \
conversions.c \
@@ -55,7 +55,8 @@ SRCS = err.c \
circuit_breaker_params.c
ifeq ($(PX4_TARGET_OS),nuttx)
SRCS += up_cxxinitialize.c
SRCS += err.c \
up_cxxinitialize.c
endif
ifneq ($(PX4_TARGET_OS),qurt)