RF24Log  0.1.3
Unified logging library
RF24LogDualHandler.cpp
Go to the documentation of this file.
1 
17 #include "RF24LogDualHandler.h"
18 
20  RF24LogBaseHandler *handler2)
21 {
22  this->handler1 = handler1;
23  this->handler2 = handler2;
24 }
25 
26 void RF24LogDualHandler::log(uint8_t logLevel,
27  const char *vendorId,
28  const char *message,
29  va_list *args)
30 {
31  // va_list can be iterated only once.
32  // Since we have here two handlers, we need to copy arguments.
33  va_list args2;
34  va_copy(args2, *args);
35 
36  // redirect logs to wrapped handlers
37  handler1->log(logLevel, vendorId, message, args);
38  handler2->log(logLevel, vendorId, message, &args2);
39  va_end(args2);
40 }
41 
42 void RF24LogDualHandler::setLogLevel(uint8_t logLevel)
43 {
44  handler1->setLogLevel(logLevel);
45  handler2->setLogLevel(logLevel);
46 }
47 
48 #if defined (ARDUINO_ARCH_AVR)
49 void RF24LogDualHandler::log(uint8_t logLevel,
50  const __FlashStringHelper *vendorId,
51  const __FlashStringHelper *message,
52  va_list *args)
53 {
54  // va_list can be iterated only once.
55  // Since we have here two handlers, we need to copy arguments.
56  va_list args2;
57  va_copy(args2, *args);
58 
59  // redirect logs to wrapped handlers
60  handler1->log(logLevel, vendorId, message, args);
61  handler2->log(logLevel, vendorId, message, &args2);
62  va_end(args2);
63 }
64 #endif
handler extention to manage 2 handlers
A base mechanism for handling log messages.
virtual void setLogLevel(uint8_t logLevel)=0
virtual void log(uint8_t logLevel, const char *vendorId, const char *message, va_list *args)=0
log a message.
void log(uint8_t logLevel, const char *vendorId, const char *message, va_list *args)
log a message.
RF24LogDualHandler(RF24LogBaseHandler *handler1, RF24LogBaseHandler *handler2)
Instance constructor.
void setLogLevel(uint8_t logLevel)