mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-24 07:09:48 +08:00
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)
This commit is contained in:
@@ -4,7 +4,6 @@
|
||||
#include <execinfo.h>
|
||||
#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_color[_PX4_LOG_LEVEL_PANIC + 1] =
|
||||
@@ -33,18 +32,16 @@ void px4_backtrace()
|
||||
|
||||
__EXPORT void px4_log_modulename(int level, const char *moduleName, const char *fmt, ...)
|
||||
{
|
||||
if (level <= __px4_log_level_current) {
|
||||
PX4_LOG_COLOR_START
|
||||
printf(__px4__log_level_fmt __px4__log_level_arg(level));
|
||||
PX4_LOG_COLOR_MODULE
|
||||
printf(__px4__log_modulename_pfmt, moduleName);
|
||||
PX4_LOG_COLOR_MESSAGE
|
||||
va_list argptr;
|
||||
va_start(argptr, fmt);
|
||||
vprintf(fmt, argptr);
|
||||
va_end(argptr);
|
||||
PX4_LOG_COLOR_END
|
||||
printf("\n");
|
||||
}
|
||||
PX4_LOG_COLOR_START
|
||||
printf(__px4__log_level_fmt __px4__log_level_arg(level));
|
||||
PX4_LOG_COLOR_MODULE
|
||||
printf(__px4__log_modulename_pfmt, moduleName);
|
||||
PX4_LOG_COLOR_MESSAGE
|
||||
va_list argptr;
|
||||
va_start(argptr, fmt);
|
||||
vprintf(fmt, argptr);
|
||||
va_end(argptr);
|
||||
PX4_LOG_COLOR_END
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
|
||||
@@ -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_color[_PX4_LOG_LEVEL_PANIC + 1];
|
||||
__EXPORT extern int __px4_log_level_current;
|
||||
__EXPORT extern void px4_backtrace(void);
|
||||
__EXPORT void px4_log_modulename(int level, const char *moduleName, const char *fmt, ...);
|
||||
|
||||
@@ -138,21 +137,18 @@ __END_DECLS
|
||||
|
||||
#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
|
||||
*
|
||||
* To write to a specific stream for each message type, open the streams and
|
||||
* 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
|
||||
* "}" 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_printline(level, ...) if (level <= __px4_log_level_current) printf(__VA_ARGS__)
|
||||
#define __px4__log_printline(level, ...) printf(__VA_ARGS__)
|
||||
|
||||
|
||||
#ifndef MODULE_NAME
|
||||
|
||||
Reference in New Issue
Block a user