| 48 | } |
| 49 | |
| 50 | size_t LogStreamClass::printf(const char * format, ...) { |
| 51 | // https://stackoverflow.com/questions/3530771/passing-variable-arguments-to-another-function-that-accepts-a-variable-argument |
| 52 | // https://stackoverflow.com/questions/1056411/how-to-pass-variable-number-of-arguments-to-printf-sprintf |
| 53 | |
| 54 | size_t res; |
| 55 | va_list args; |
| 56 | va_start(args, format); |
| 57 | |
| 58 | // maximum number of characters in log message |
| 59 | char buf[1000]; |
| 60 | vsnprintf(buf, sizeof(buf), format, args); |
| 61 | |
| 62 | // print out #1: Serial |
| 63 | #if defined(useSerial) |
| 64 | res = Serial.printf(MY_LOG_FORMAT("%s"), buf); |
| 65 | #endif |
| 66 | |
| 67 | // print out #2: TelnetStream |
| 68 | #if defined(useTelnetStream) |
| 69 | res = TelnetStream.printf(MY_LOG_FORMAT("%s"), buf); |
| 70 | #endif |
| 71 | |
| 72 | va_end(args); |
| 73 | return res; |
| 74 | }; |
| 75 | |
| 76 | LogStreamClass Log; |
| 77 |
no outgoing calls
no test coverage detected