Browse Source

px4_log: remove __px4_log_level_current

- there is no way to change it at runtime
- it was implemented wrong (<= comparison disabled the PANIC log level)
sbg
Beat Küng 9 years ago
parent
commit
6b4c24fb12
  1. 3
      src/platforms/posix/px4_layer/px4_log.c
  2. 8
      src/platforms/px4_log.h

3
src/platforms/posix/px4_layer/px4_log.c

@ -4,7 +4,6 @@
#include <execinfo.h> #include <execinfo.h>
#endif #endif
__EXPORT int __px4_log_level_current = PX4_LOG_LEVEL_AT_RUN_TIME;
__EXPORT const char *__px4_log_level_str[_PX4_LOG_LEVEL_PANIC + 1] = { "INFO", "DEBUG", "WARN", "ERROR", "PANIC" }; __EXPORT const char *__px4_log_level_str[_PX4_LOG_LEVEL_PANIC + 1] = { "INFO", "DEBUG", "WARN", "ERROR", "PANIC" };
__EXPORT const char *__px4_log_level_color[_PX4_LOG_LEVEL_PANIC + 1] = __EXPORT const char *__px4_log_level_color[_PX4_LOG_LEVEL_PANIC + 1] =
@ -33,7 +32,6 @@ void px4_backtrace()
__EXPORT void px4_log_modulename(int level, const char *moduleName, const char *fmt, ...) __EXPORT void px4_log_modulename(int level, const char *moduleName, const char *fmt, ...)
{ {
if (level <= __px4_log_level_current) {
PX4_LOG_COLOR_START PX4_LOG_COLOR_START
printf(__px4__log_level_fmt __px4__log_level_arg(level)); printf(__px4__log_level_fmt __px4__log_level_arg(level));
PX4_LOG_COLOR_MODULE PX4_LOG_COLOR_MODULE
@ -45,6 +43,5 @@ __EXPORT void px4_log_modulename(int level, const char *moduleName, const char *
va_end(argptr); va_end(argptr);
PX4_LOG_COLOR_END PX4_LOG_COLOR_END
printf("\n"); printf("\n");
}
} }

8
src/platforms/px4_log.h

@ -130,7 +130,6 @@ __BEGIN_DECLS
__EXPORT extern const char *__px4_log_level_str[_PX4_LOG_LEVEL_PANIC + 1]; __EXPORT extern const char *__px4_log_level_str[_PX4_LOG_LEVEL_PANIC + 1];
__EXPORT extern const char *__px4_log_level_color[_PX4_LOG_LEVEL_PANIC + 1]; __EXPORT extern const char *__px4_log_level_color[_PX4_LOG_LEVEL_PANIC + 1];
__EXPORT extern int __px4_log_level_current;
__EXPORT extern void px4_backtrace(void); __EXPORT extern void px4_backtrace(void);
__EXPORT void px4_log_modulename(int level, const char *moduleName, const char *fmt, ...); __EXPORT void px4_log_modulename(int level, const char *moduleName, const char *fmt, ...);
@ -138,21 +137,18 @@ __END_DECLS
#define PX4_BACKTRACE() px4_backtrace() #define PX4_BACKTRACE() px4_backtrace()
// __px4_log_level_current will be initialized to PX4_LOG_LEVEL_AT_RUN_TIME
#define PX4_LOG_LEVEL_AT_RUN_TIME _PX4_LOG_LEVEL_ERROR
/**************************************************************************** /****************************************************************************
* Implementation of log section formatting based on printf * Implementation of log section formatting based on printf
* *
* To write to a specific stream for each message type, open the streams and * To write to a specific stream for each message type, open the streams and
* set __px4__log_startline to something like: * set __px4__log_startline to something like:
* if (level <= __px4_log_level_current) printf(_px4_fd[level], * printf(_px4_fd[level],
* *
* Additional behavior can be added using "{\" for __px4__log_startline and * Additional behavior can be added using "{\" for __px4__log_startline and
* "}" for __px4__log_endline and any other required setup or teardown steps * "}" for __px4__log_endline and any other required setup or teardown steps
****************************************************************************/ ****************************************************************************/
#define __px4__log_printcond(cond, ...) if (cond) printf(__VA_ARGS__) #define __px4__log_printcond(cond, ...) if (cond) printf(__VA_ARGS__)
#define __px4__log_printline(level, ...) if (level <= __px4_log_level_current) printf(__VA_ARGS__) #define __px4__log_printline(level, ...) printf(__VA_ARGS__)
#ifndef MODULE_NAME #ifndef MODULE_NAME

Loading…
Cancel
Save