Library for LoRa communication using MultiTech MDOT.
Dependents: mDot_LoRa_Connect_CSA_Light mDot_LoRa_Connect_CSA_RH_Temp
Fork of libmDot by
MTS-Utils/MTSLog.h@9:ebf682e616d0, 2015-09-10 (annotated)
- Committer:
- Mike Fiore
- Date:
- Thu Sep 10 13:16:42 2015 -0500
- Revision:
- 9:ebf682e616d0
- Parent:
- MTSLog.h@7:683dba5d576f
- Child:
- 11:9938ba31d428
update README, move files into new directory structure
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 |
7:683dba5d576f | 13 | mts::MTSLog::printMessage(mts::MTSLog::FATAL_LEVEL, "%s:%s:%s| [%s] " format "\r\n", __FILE__, __func__, __LINE__, mts::MTSLog::FATAL_LABEL, ##__VA_ARGS__) |
Mike Fiore |
1:9f30fbe9e9c1 | 14 | #define logError(format, ...) \ |
Mike Fiore |
7:683dba5d576f | 15 | mts::MTSLog::printMessage(mts::MTSLog::ERROR_LEVEL, "%s:%s:%s| [%s] " format "\r\n", __FILE__, __func__, __LINE__, mts::MTSLog::ERROR_LABEL, ##__VA_ARGS__) |
Mike Fiore |
1:9f30fbe9e9c1 | 16 | #define logWarning(format, ...) \ |
Mike Fiore |
7:683dba5d576f | 17 | mts::MTSLog::printMessage(mts::MTSLog::WARNING_LEVEL, "%s:%s:%s| [%s] " format "\r\n", __FILE__, __func__, __LINE__, mts::MTSLog::WARNING_LABEL, ##__VA_ARGS__) |
Mike Fiore |
1:9f30fbe9e9c1 | 18 | #define logInfo(format, ...) \ |
Mike Fiore |
7:683dba5d576f | 19 | mts::MTSLog::printMessage(mts::MTSLog::INFO_LEVEL, "%s:%s:%s| [%s] " format "\r\n", __FILE__, __func__, __LINE__, mts::MTSLog::INFO_LABEL, ##__VA_ARGS__) |
Mike Fiore |
1:9f30fbe9e9c1 | 20 | #define logDebug(format, ...) \ |
Mike Fiore |
7:683dba5d576f | 21 | mts::MTSLog::printMessage(mts::MTSLog::DEBUG_LEVEL, "%s:%s:%s| [%s] " format "\r\n", __FILE__, __func__, __LINE__, mts::MTSLog::DEBUG_LABEL, ##__VA_ARGS__) |
Mike Fiore |
1:9f30fbe9e9c1 | 22 | #define logTrace(format, ...) \ |
Mike Fiore |
7:683dba5d576f | 23 | mts::MTSLog::printMessage(mts::MTSLog::TRACE_LEVEL, "%s:%s:%s| [%s] " format "\r\n", __FILE__, __func__, __LINE__, mts::MTSLog::TRACE_LABEL, ##__VA_ARGS__) |
Mike Fiore |
1:9f30fbe9e9c1 | 24 | #else |
Mike Fiore |
1:9f30fbe9e9c1 | 25 | #define logFatal(format, ...) \ |
Mike Fiore |
7:683dba5d576f | 26 | mts::MTSLog::printMessage(mts::MTSLog::FATAL_LEVEL, "[%s] " format "\r\n", mts::MTSLog::FATAL_LABEL, ##__VA_ARGS__) |
Mike Fiore |
1:9f30fbe9e9c1 | 27 | #define logError(format, ...) \ |
Mike Fiore |
7:683dba5d576f | 28 | mts::MTSLog::printMessage(mts::MTSLog::ERROR_LEVEL, "[%s] " format "\r\n", mts::MTSLog::ERROR_LABEL, ##__VA_ARGS__) |
Mike Fiore |
1:9f30fbe9e9c1 | 29 | #define logWarning(format, ...) \ |
Mike Fiore |
7:683dba5d576f | 30 | mts::MTSLog::printMessage(mts::MTSLog::WARNING_LEVEL, "[%s] " format "\r\n", mts::MTSLog::WARNING_LABEL, ##__VA_ARGS__) |
Mike Fiore |
1:9f30fbe9e9c1 | 31 | #define logInfo(format, ...) \ |
Mike Fiore |
7:683dba5d576f | 32 | mts::MTSLog::printMessage(mts::MTSLog::INFO_LEVEL, "[%s] " format "\r\n", mts::MTSLog::INFO_LABEL, ##__VA_ARGS__) |
Mike Fiore |
1:9f30fbe9e9c1 | 33 | #define logDebug(format, ...) \ |
Mike Fiore |
7:683dba5d576f | 34 | mts::MTSLog::printMessage(mts::MTSLog::DEBUG_LEVEL, "[%s] " format "\r\n", mts::MTSLog::DEBUG_LABEL, ##__VA_ARGS__) |
Mike Fiore |
1:9f30fbe9e9c1 | 35 | #define logTrace(format, ...) \ |
Mike Fiore |
7:683dba5d576f | 36 | mts::MTSLog::printMessage(mts::MTSLog::TRACE_LEVEL, "[%s] " format "\r\n", mts::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 |