mirror of
https://github.com/meshtastic/firmware.git
synced 2025-04-25 09:42:35 +00:00
Log levels log function
This commit is contained in:
parent
0b5cae5393
commit
3eefd46ca1
@ -29,10 +29,10 @@
|
||||
#define LOG_ERROR(...) SEGGER_RTT_printf(0, __VA_ARGS__)
|
||||
#else
|
||||
#ifdef DEBUG_PORT
|
||||
#define LOG_DEBUG(...) DEBUG_PORT.logDebug(__VA_ARGS__)
|
||||
#define LOG_INFO(...) DEBUG_PORT.logDebug(__VA_ARGS__)
|
||||
#define LOG_WARN(...) DEBUG_PORT.logDebug(__VA_ARGS__)
|
||||
#define LOG_ERROR(...) DEBUG_PORT.logDebug(__VA_ARGS__)
|
||||
#define LOG_DEBUG(...) DEBUG_PORT.log(LOG_LEVEL_DEBUG, __VA_ARGS__)
|
||||
#define LOG_INFO(...) DEBUG_PORT.log(LOG_LEVEL_INFO, __VA_ARGS__)
|
||||
#define LOG_WARN(...) DEBUG_PORT.log(LOG_LEVEL_WARN, __VA_ARGS__)
|
||||
#define LOG_ERROR(...) DEBUG_PORT.log(LOG_LEVEL_ERROR, __VA_ARGS__)
|
||||
#else
|
||||
#define LOG_DEBUG(...)
|
||||
#define LOG_INFO(...)
|
||||
|
@ -58,7 +58,7 @@ size_t RedirectablePrint::vprintf(const char *format, va_list arg)
|
||||
return len;
|
||||
}
|
||||
|
||||
size_t RedirectablePrint::logDebug(const char *format, ...)
|
||||
size_t RedirectablePrint::log(const char *logLevel, const char *format, ...)
|
||||
{
|
||||
size_t r = 0;
|
||||
|
||||
@ -86,9 +86,9 @@ size_t RedirectablePrint::logDebug(const char *format, ...)
|
||||
int min = (hms % SEC_PER_HOUR) / SEC_PER_MIN;
|
||||
int sec = (hms % SEC_PER_HOUR) % SEC_PER_MIN; // or hms % SEC_PER_MIN
|
||||
|
||||
r += printf("%02d:%02d:%02d %u ", hour, min, sec, millis() / 1000);
|
||||
r += printf("%s | %02d:%02d:%02d %u ", logLevel, hour, min, sec, millis() / 1000);
|
||||
} else
|
||||
r += printf("??:??:?? %u ", millis() / 1000);
|
||||
r += printf("%s | ??:??:?? %u ", logLevel, millis() / 1000);
|
||||
|
||||
auto thread = concurrency::OSThread::currentThread;
|
||||
if (thread) {
|
||||
@ -99,7 +99,6 @@ size_t RedirectablePrint::logDebug(const char *format, ...)
|
||||
print("] ");
|
||||
}
|
||||
}
|
||||
|
||||
r += vprintf(format, arg);
|
||||
va_end(arg);
|
||||
|
||||
|
@ -34,7 +34,7 @@ class RedirectablePrint : public Print
|
||||
* log message. Otherwise we assume more prints will come before the log message ends. This
|
||||
* allows you to call logDebug a few times to build up a single log message line if you wish.
|
||||
*/
|
||||
size_t logDebug(const char * format, ...) __attribute__ ((format (printf, 2, 3)));
|
||||
size_t log(const char *logLevel, const char *format, ...) __attribute__ ((format (printf, 3, 4)));
|
||||
|
||||
/** like printf but va_list based */
|
||||
size_t vprintf(const char *format, va_list arg);
|
||||
|
Loading…
Reference in New Issue
Block a user