Add formated loging for device detection

Commits merged and amended for code style by Adam Honse <calcprogrammer1@gmail.com>
This commit is contained in:
Alex 2021-06-16 04:26:15 +02:00 committed by Adam Honse
parent 5a7879415f
commit 4af8614fce
19 changed files with 213 additions and 111 deletions

View file

@ -12,13 +12,13 @@ using json = nlohmann::json;
enum
{
LL_CRITICAL, // Critical unrecoverable errors that cause a generalized crash of a module or of the entire app
LL_FATAL, // Critical unrecoverable errors that cause a generalized crash of a module or of the entire app
LL_ERROR, // Local errors that abort an operation
LL_MESSAGE, // Things the user should be informed of, not necessarily errors
LL_WARNING, // Local errors that may cause an operation to have an undefined behavior or may have dangerous/unforeseen consequences
LL_NOTICE, // Initialization messages, significant actions and follow-up information
LL_INFO, // Initialization messages, significant actions and follow-up information
LL_VERBOSE, // Tracing of commands and performed actions, usually for debug purposes, comments on the higher priority messages
LL_DEBUG, // Deep tracing, "printf-style debugging" alternative, for debug purposes. Such messages should be put all over the code instead of comments
LL_TRACE
};
struct LogMessage
@ -27,6 +27,7 @@ struct LogMessage
unsigned int level;
const char* filename;
int line;
clock_t counted_second;
// int timestamp or float time_offset? TBD
};
typedef std::shared_ptr<LogMessage> PLogMessage;
@ -53,11 +54,14 @@ private:
bool print_source = false;
// Logfile max level
unsigned int loglevel = LL_NOTICE;
unsigned int loglevel = LL_INFO;
// Verbosity (stdout) max level
unsigned int verbosity = LL_WARNING;
//Clock from LogManager creation
clock_t base_clock;
// A non-guarded append()
void _append(const char* filename, int line, unsigned int level, const char* fmt, va_list va);
@ -79,12 +83,12 @@ public:
};
#define LogAppend(level, ...) LogManager::get()->append(__FILE__, __LINE__, level, __VA_ARGS__)
#define LOG_CRITICAL(...) LogAppend(LL_CRITICAL, __VA_ARGS__)
#define LOG_FATAL(...) LogAppend(LL_FATAL, __VA_ARGS__)
#define LOG_ERROR(...) LogAppend(LL_ERROR, __VA_ARGS__)
#define LOG_MESSAGE(...) LogAppend(LL_MESSAGE, __VA_ARGS__)
#define LOG_WARNING(...) LogAppend(LL_WARNING, __VA_ARGS__)
#define LOG_NOTICE(...) LogAppend(LL_NOTICE, __VA_ARGS__)
#define LOG_INFO(...) LogAppend(LL_INFO, __VA_ARGS__)
#define LOG_VERBOSE(...) LogAppend(LL_VERBOSE, __VA_ARGS__)
#define LOG_DEBUG(...) LogAppend(LL_DEBUG, __VA_ARGS__)
#define LOG_TRACE(...) LogAppend(LL_TRACE, __VA_ARGS__)
#endif // LOGMANAGER_H