Library for LoRa communication using MultiTech MDOT.
Dependents: mDot_LoRa_Connect_CSA_Light mDot_LoRa_Connect_CSA_RH_Temp
Fork of libmDot by
MTSLog.h@1:9f30fbe9e9c1, 2015-06-24 (annotated)
- Committer:
- Mike Fiore
- Date:
- Wed Jun 24 17:03:08 2015 -0500
- Revision:
- 1:9f30fbe9e9c1
- Child:
- 7:683dba5d576f
add README, LICENSE, headers, and library - from git tag mbed_24June2015
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Mike Fiore |
1:9f30fbe9e9c1 | 1 | /************************************************ |
Mike Fiore |
1:9f30fbe9e9c1 | 2 | * MultiTech MTDOT Library |
Mike Fiore |
1:9f30fbe9e9c1 | 3 | * Copyright (c) 2015 MultiTech Systems |
Mike Fiore |
1:9f30fbe9e9c1 | 4 | * |
Mike Fiore |
1:9f30fbe9e9c1 | 5 | * See LICENSE file for license information |
Mike Fiore |
1:9f30fbe9e9c1 | 6 | ***********************************************/ |
Mike Fiore |
1:9f30fbe9e9c1 | 7 | |
Mike Fiore |
1:9f30fbe9e9c1 | 8 | #ifndef MTSLOG_H |
Mike Fiore |
1:9f30fbe9e9c1 | 9 | #define MTSLOG_H |
Mike Fiore |
1:9f30fbe9e9c1 | 10 | |
Mike Fiore |
1:9f30fbe9e9c1 | 11 | #ifdef MTS_DEBUG |
Mike Fiore |
1:9f30fbe9e9c1 | 12 | #define logFatal(format, ...) \ |
Mike Fiore |
1:9f30fbe9e9c1 | 13 | MTSLog::printMessage(MTSLog::FATAL_LEVEL, "%s:%s:%s| [%s] " format "\r\n", __FILE__, __func__, __LINE__, MTSLog::FATAL_LABEL, ##__VA_ARGS__) |
Mike Fiore |
1:9f30fbe9e9c1 | 14 | #define logError(format, ...) \ |
Mike Fiore |
1:9f30fbe9e9c1 | 15 | MTSLog::printMessage(MTSLog::ERROR_LEVEL, "%s:%s:%s| [%s] " format "\r\n", __FILE__, __func__, __LINE__, MTSLog::ERROR_LABEL, ##__VA_ARGS__) |
Mike Fiore |
1:9f30fbe9e9c1 | 16 | #define logWarning(format, ...) \ |
Mike Fiore |
1:9f30fbe9e9c1 | 17 | MTSLog::printMessage(MTSLog::WARNING_LEVEL, "%s:%s:%s| [%s] " format "\r\n", __FILE__, __func__, __LINE__, MTSLog::WARNING_LABEL, ##__VA_ARGS__) |
Mike Fiore |
1:9f30fbe9e9c1 | 18 | #define logInfo(format, ...) \ |
Mike Fiore |
1:9f30fbe9e9c1 | 19 | MTSLog::printMessage(MTSLog::INFO_LEVEL, "%s:%s:%s| [%s] " format "\r\n", __FILE__, __func__, __LINE__, MTSLog::INFO_LABEL, ##__VA_ARGS__) |
Mike Fiore |
1:9f30fbe9e9c1 | 20 | #define logDebug(format, ...) \ |
Mike Fiore |
1:9f30fbe9e9c1 | 21 | MTSLog::printMessage(MTSLog::DEBUG_LEVEL, "%s:%s:%s| [%s] " format "\r\n", __FILE__, __func__, __LINE__, MTSLog::DEBUG_LABEL, ##__VA_ARGS__) |
Mike Fiore |
1:9f30fbe9e9c1 | 22 | #define logTrace(format, ...) \ |
Mike Fiore |
1:9f30fbe9e9c1 | 23 | MTSLog::printMessage(MTSLog::TRACE_LEVEL, "%s:%s:%s| [%s] " format "\r\n", __FILE__, __func__, __LINE__, MTSLog::TRACE_LABEL, ##__VA_ARGS__) |
Mike Fiore |
1:9f30fbe9e9c1 | 24 | #else |
Mike Fiore |
1:9f30fbe9e9c1 | 25 | #define logFatal(format, ...) \ |
Mike Fiore |
1:9f30fbe9e9c1 | 26 | MTSLog::printMessage(MTSLog::FATAL_LEVEL, "[%s] " format "\r\n", MTSLog::FATAL_LABEL, ##__VA_ARGS__) |
Mike Fiore |
1:9f30fbe9e9c1 | 27 | #define logError(format, ...) \ |
Mike Fiore |
1:9f30fbe9e9c1 | 28 | MTSLog::printMessage(MTSLog::ERROR_LEVEL, "[%s] " format "\r\n", MTSLog::ERROR_LABEL, ##__VA_ARGS__) |
Mike Fiore |
1:9f30fbe9e9c1 | 29 | #define logWarning(format, ...) \ |
Mike Fiore |
1:9f30fbe9e9c1 | 30 | MTSLog::printMessage(MTSLog::WARNING_LEVEL, "[%s] " format "\r\n", MTSLog::WARNING_LABEL, ##__VA_ARGS__) |
Mike Fiore |
1:9f30fbe9e9c1 | 31 | #define logInfo(format, ...) \ |
Mike Fiore |
1:9f30fbe9e9c1 | 32 | MTSLog::printMessage(MTSLog::INFO_LEVEL, "[%s] " format "\r\n", MTSLog::INFO_LABEL, ##__VA_ARGS__) |
Mike Fiore |
1:9f30fbe9e9c1 | 33 | #define logDebug(format, ...) \ |
Mike Fiore |
1:9f30fbe9e9c1 | 34 | MTSLog::printMessage(MTSLog::DEBUG_LEVEL, "[%s] " format "\r\n", MTSLog::DEBUG_LABEL, ##__VA_ARGS__) |
Mike Fiore |
1:9f30fbe9e9c1 | 35 | #define logTrace(format, ...) \ |
Mike Fiore |
1:9f30fbe9e9c1 | 36 | MTSLog::printMessage(MTSLog::TRACE_LEVEL, "[%s] " format "\r\n", MTSLog::TRACE_LABEL, ##__VA_ARGS__) |
Mike Fiore |
1:9f30fbe9e9c1 | 37 | #endif |
Mike Fiore |
1:9f30fbe9e9c1 | 38 | |
Mike Fiore |
1:9f30fbe9e9c1 | 39 | namespace mts { |
Mike Fiore |
1:9f30fbe9e9c1 | 40 | |
Mike Fiore |
1:9f30fbe9e9c1 | 41 | class MTSLog |
Mike Fiore |
1:9f30fbe9e9c1 | 42 | { |
Mike Fiore |
1:9f30fbe9e9c1 | 43 | public: |
Mike Fiore |
1:9f30fbe9e9c1 | 44 | |
Mike Fiore |
1:9f30fbe9e9c1 | 45 | /** Enum of log levels. |
Mike Fiore |
1:9f30fbe9e9c1 | 46 | */ |
Mike Fiore |
1:9f30fbe9e9c1 | 47 | enum logLevel { |
Mike Fiore |
1:9f30fbe9e9c1 | 48 | NONE_LEVEL = 0, |
Mike Fiore |
1:9f30fbe9e9c1 | 49 | FATAL_LEVEL = 1, |
Mike Fiore |
1:9f30fbe9e9c1 | 50 | ERROR_LEVEL = 2, |
Mike Fiore |
1:9f30fbe9e9c1 | 51 | WARNING_LEVEL = 3, |
Mike Fiore |
1:9f30fbe9e9c1 | 52 | INFO_LEVEL = 4, |
Mike Fiore |
1:9f30fbe9e9c1 | 53 | DEBUG_LEVEL = 5, |
Mike Fiore |
1:9f30fbe9e9c1 | 54 | TRACE_LEVEL = 6 |
Mike Fiore |
1:9f30fbe9e9c1 | 55 | }; |
Mike Fiore |
1:9f30fbe9e9c1 | 56 | |
Mike Fiore |
1:9f30fbe9e9c1 | 57 | /** Print log message. |
Mike Fiore |
1:9f30fbe9e9c1 | 58 | */ |
Mike Fiore |
1:9f30fbe9e9c1 | 59 | static void printMessage(int level, const char* format, ...); |
Mike Fiore |
1:9f30fbe9e9c1 | 60 | |
Mike Fiore |
1:9f30fbe9e9c1 | 61 | /** Determine if the given level is currently printable. |
Mike Fiore |
1:9f30fbe9e9c1 | 62 | */ |
Mike Fiore |
1:9f30fbe9e9c1 | 63 | static bool printable(int level); |
Mike Fiore |
1:9f30fbe9e9c1 | 64 | |
Mike Fiore |
1:9f30fbe9e9c1 | 65 | /** Set log level |
Mike Fiore |
1:9f30fbe9e9c1 | 66 | * Messages with lower priority than the current level will not be printed. |
Mike Fiore |
1:9f30fbe9e9c1 | 67 | * If the level is set to NONE, no messages will print. |
Mike Fiore |
1:9f30fbe9e9c1 | 68 | */ |
Mike Fiore |
1:9f30fbe9e9c1 | 69 | static void setLogLevel(int level); |
Mike Fiore |
1:9f30fbe9e9c1 | 70 | |
Mike Fiore |
1:9f30fbe9e9c1 | 71 | /** Get the current log level. |
Mike Fiore |
1:9f30fbe9e9c1 | 72 | */ |
Mike Fiore |
1:9f30fbe9e9c1 | 73 | static int getLogLevel(); |
Mike Fiore |
1:9f30fbe9e9c1 | 74 | |
Mike Fiore |
1:9f30fbe9e9c1 | 75 | /** Get string representation of the current log level. |
Mike Fiore |
1:9f30fbe9e9c1 | 76 | */ |
Mike Fiore |
1:9f30fbe9e9c1 | 77 | static const char* getLogLevelString(); |
Mike Fiore |
1:9f30fbe9e9c1 | 78 | |
Mike Fiore |
1:9f30fbe9e9c1 | 79 | static const char* NONE_LABEL; |
Mike Fiore |
1:9f30fbe9e9c1 | 80 | static const char* FATAL_LABEL; |
Mike Fiore |
1:9f30fbe9e9c1 | 81 | static const char* ERROR_LABEL; |
Mike Fiore |
1:9f30fbe9e9c1 | 82 | static const char* WARNING_LABEL; |
Mike Fiore |
1:9f30fbe9e9c1 | 83 | static const char* INFO_LABEL; |
Mike Fiore |
1:9f30fbe9e9c1 | 84 | static const char* DEBUG_LABEL; |
Mike Fiore |
1:9f30fbe9e9c1 | 85 | static const char* TRACE_LABEL; |
Mike Fiore |
1:9f30fbe9e9c1 | 86 | |
Mike Fiore |
1:9f30fbe9e9c1 | 87 | private: |
Mike Fiore |
1:9f30fbe9e9c1 | 88 | |
Mike Fiore |
1:9f30fbe9e9c1 | 89 | /** Constructor |
Mike Fiore |
1:9f30fbe9e9c1 | 90 | */ |
Mike Fiore |
1:9f30fbe9e9c1 | 91 | MTSLog(); |
Mike Fiore |
1:9f30fbe9e9c1 | 92 | |
Mike Fiore |
1:9f30fbe9e9c1 | 93 | static int currentLevel; |
Mike Fiore |
1:9f30fbe9e9c1 | 94 | |
Mike Fiore |
1:9f30fbe9e9c1 | 95 | }; |
Mike Fiore |
1:9f30fbe9e9c1 | 96 | |
Mike Fiore |
1:9f30fbe9e9c1 | 97 | } |
Mike Fiore |
1:9f30fbe9e9c1 | 98 | |
Mike Fiore |
1:9f30fbe9e9c1 | 99 | #endif |