RF24Log  0.1.3
Unified logging library
RF24Logging.h
Go to the documentation of this file.
1 
16 #ifndef SRC_RF24LOGGER_H_
17 #define SRC_RF24LOGGER_H_
18 
19 #if defined (ARDUINO_ARCH_AVR)
20 #include <WString.h> // __FlashStringHelper
21 #else
22 #include <string.h>
23 #endif
24 
31 #include "RF24LogLevel.h"
32 #include "RF24LogBaseHandler.h"
33 
34 #if defined (ARDUINO_ARCH_AVR)
35  #define RF24LOG_FLASHIFY(A) F(A)
36  #define RF24Log_error(vendorId, message, ...) (rf24Logging.log(RF24LogLevel::ERROR, (const __FlashStringHelper*)(vendorId), RF24LOG_FLASHIFY(message), ##__VA_ARGS__))
37  #define RF24Log_warn(vendorId, message, ...) (rf24Logging.log(RF24LogLevel::WARN, (const __FlashStringHelper*)(vendorId), RF24LOG_FLASHIFY(message), ##__VA_ARGS__))
38  #define RF24Log_info(vendorId, message, ...) (rf24Logging.log(RF24LogLevel::INFO, (const __FlashStringHelper*)(vendorId), RF24LOG_FLASHIFY(message), ##__VA_ARGS__))
39  #define RF24Log_debug(vendorId, message, ...) (rf24Logging.log(RF24LogLevel::DEBUG, (const __FlashStringHelper*)(vendorId), RF24LOG_FLASHIFY(message), ##__VA_ARGS__))
40  #define RF24Log_log(logLevel, vendorId, message, ...) (rf24Logging.log(logLevel, (const __FlashStringHelper*)(vendorId), RF24LOG_FLASHIFY(message), ##__VA_ARGS__))
41 #else
42 
50  #define RF24Log_error(vendorId, message, ...) (rf24Logging.log(RF24LogLevel::ERROR, vendorId, message, ##__VA_ARGS__))
51 
59  #define RF24Log_warn(vendorId, message, ...) (rf24Logging.log(RF24LogLevel::WARN, vendorId, message, ##__VA_ARGS__))
60 
68  #define RF24Log_info(vendorId, message, ...) (rf24Logging.log(RF24LogLevel::INFO, vendorId, message, ##__VA_ARGS__))
69 
77  #define RF24Log_debug(vendorId, message, ...) (rf24Logging.log(RF24LogLevel::DEBUG, vendorId, message, ##__VA_ARGS__))
78 
88  #define RF24Log_log(logLevel, vendorId, message, ...) (rf24Logging.log(logLevel, vendorId, message, ##__VA_ARGS__))
89 #endif
90 
93 {
94 private:
96  RF24LogBaseHandler *handler;
97 
98 public:
100  RF24Logging();
101 
106  void setHandler(RF24LogBaseHandler *handler);
107 
116  void log(uint8_t logLevel, const char *vendorId, const char *message, ...);
117 
118 #if defined (ARDUINO_ARCH_AVR)
119  void log(uint8_t logLevel, const __FlashStringHelper *vendorId, const __FlashStringHelper *message, ...);
120 #endif
121 };
122 
124 extern RF24Logging rf24Logging;
125 
128 #endif /* SRC_RF24LOGGER_H_ */
129 
inherent declarations for all handlers.
Order of log levels and filtering.
A base mechanism for handling log messages.
This is the end-user's access point into the world of logging messages.
Definition: RF24Logging.h:93
void log(uint8_t logLevel, const char *vendorId, const char *message,...)
output a log message of any level
Definition: RF24Logging.cpp:32
RF24Logging()
Initializes the handler to nullptr.
Definition: RF24Logging.cpp:18
void setHandler(RF24LogBaseHandler *handler)
set the instance's handler
Definition: RF24Logging.cpp:25
RF24Logging rf24Logging
the singleton used for all your program's logging purposes.
Definition: RF24Logging.cpp:61