Closed bobemoe closed 1 year ago
I think I have a solution to this. I have made my changes on my fork of the project, perhaps they can be merged?
Before you #include <DebugLog.h>
simply define a LOG_PREAMBLE macro.
#define LOG_PREAMBLE __LINE__, __func__, "This string will go before all log statements: "
#include <DebugLog.h>
// Before the log macros looked like this
#define LOG_ERROR(...) DebugLog::Manager::get().log(arx::debug::LogLevel::LVL_ERROR, LOG_SHORT_FILENAME, __LINE__, __func__, __VA_ARGS__)
// Now it looks like this
#define LOG_ERROR(...) DebugLog::Manager::get().log(arx::debug::LogLevel::LVL_ERROR, LOG_SHORT_FILENAME, LOG_PREAMBLE, __VA_ARGS__)
I realize this addresses the "Custom log format" part of your question but not the "add timestamp" part. For adding a timestamp you will have to define your own timestamp function and make a call to that when defining LOG_PREAMBLE
Like so:
#define LOG_PREAMBLE __LINE__, __func__, get_time()
#include <DebugLog.h>
Is it possible to add a custom log format? Specifically I'm wanting to prefix each log with a timestamp, either
millis()
orYYMMDDHHMMSS
if RTC is available.Instead of implementing the time handling internally, probably best bet is a custom format callback or something?
Does anything like this exists?
If not would you be interested in PR? If so any suggestion on best place to implement?