Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: MTS-Lora/vendor/multitech/MTS-Utils/MTSLog.h
- Revision:
- 65:acc0468b9aec
- Parent:
- 16:b630e18103e5
- Child:
- 72:b1e07ec1c30d
--- a/MTS-Lora/vendor/multitech/MTS-Utils/MTSLog.h Thu Aug 23 14:18:55 2018 -0500 +++ b/MTS-Lora/vendor/multitech/MTS-Utils/MTSLog.h Thu Apr 18 14:55:19 2019 -0500 @@ -16,6 +16,14 @@ #define __CLASSNAME__ className(__PRETTY_FUNCTION__) +#ifdef MTS_TIMESTAMP_LOG +#define __LOG__(logLevel, format, ...) \ + mts::MTSLog::printMessage(logLevel, "%s| [%s] " format "\r\n", \ + mts::MTSLog::getTime().c_str(), mts::MTSLog::getLogLevelString(logLevel), ##__VA_ARGS__) +#else +#define __LOG__(logLevel, format, ...) \ + mts::MTSLog::printMessage(logLevel, "[%s] " format "\r\n", mts::MTSLog::getLogLevelString(logLevel), ##__VA_ARGS__) +#endif #ifdef MTS_DEBUG #define logFatal(format, ...) \ @@ -32,17 +40,17 @@ mts::MTSLog::printMessage(mts::MTSLog::TRACE_LEVEL, "%s:%s:%d| [%s] " format "\r\n", __CLASSNAME__, __func__, __LINE__, mts::MTSLog::TRACE_LABEL, ##__VA_ARGS__) #else #define logFatal(format, ...) \ - mts::MTSLog::printMessage(mts::MTSLog::FATAL_LEVEL, "[%s] " format "\r\n", mts::MTSLog::FATAL_LABEL, ##__VA_ARGS__) + __LOG__(mts::MTSLog::FATAL_LEVEL, format, ##__VA_ARGS__) #define logError(format, ...) \ - mts::MTSLog::printMessage(mts::MTSLog::ERROR_LEVEL, "[%s] " format "\r\n", mts::MTSLog::ERROR_LABEL, ##__VA_ARGS__) + __LOG__(mts::MTSLog::ERROR_LEVEL, format, ##__VA_ARGS__) #define logWarning(format, ...) \ - mts::MTSLog::printMessage(mts::MTSLog::WARNING_LEVEL, "[%s] " format "\r\n", mts::MTSLog::WARNING_LABEL, ##__VA_ARGS__) + __LOG__(mts::MTSLog::WARNING_LEVEL, format, ##__VA_ARGS__) #define logInfo(format, ...) \ - mts::MTSLog::printMessage(mts::MTSLog::INFO_LEVEL, "[%s] " format "\r\n", mts::MTSLog::INFO_LABEL, ##__VA_ARGS__) + __LOG__(mts::MTSLog::INFO_LEVEL, format, ##__VA_ARGS__) #define logDebug(format, ...) \ - mts::MTSLog::printMessage(mts::MTSLog::DEBUG_LEVEL, "[%s] " format "\r\n", mts::MTSLog::DEBUG_LABEL, ##__VA_ARGS__) + __LOG__(mts::MTSLog::DEBUG_LEVEL, format, ##__VA_ARGS__) #define logTrace(format, ...) \ - mts::MTSLog::printMessage(mts::MTSLog::TRACE_LEVEL, "[%s] " format "\r\n", mts::MTSLog::TRACE_LABEL, ##__VA_ARGS__) + __LOG__(mts::MTSLog::TRACE_LEVEL, format, ##__VA_ARGS__) #endif namespace mts { @@ -84,6 +92,11 @@ /** Get string representation of the current log level. */ static const char* getLogLevelString(); + static const char* getLogLevelString(int level); + + /** Get a formatted time string as HH:MM:SS + */ + static std::string getTime(); static const char* NONE_LABEL; static const char* FATAL_LABEL;