AceTime  0.5
Date and time classes for Arduino that support timezones from the TZ Database, and a system clock that can synchronize from an NTP server or an RTC chip.
logger.h
1 /*
2  * MIT License
3  * Copyright (c) 2018 Brian T. Park
4  */
5 
6 /*
7  * Implement logger::print() and logger::println() that accept formatting
8  * strings like printf(). I finally got tired of writing multiple lines of
9  * Serial.print() for debugging.
10  */
11 
12 #ifndef ACE_TIME_COMMON_LOGGING_H
13 #define ACE_TIME_COMMON_LOGGING_H
14 
15 namespace ace_time {
16 namespace logging {
17 
18 #include <stdarg.h>
19 
20 inline void vprintf(const char *fmt, va_list args) {
21  char buf[192];
22  vsnprintf(buf, 192, fmt, args);
23  Serial.print(buf);
24 }
25 
27 inline void print(const char* fmt, ...) {
28  va_list args;
29  va_start(args, fmt);
30  vprintf(fmt, args);
31  va_end(args);
32 }
33 
38 inline void println(const char *fmt, ... ) {
39  va_list args;
40  va_start(args, fmt);
41  vprintf(fmt, args);
42  va_end(args);
43  Serial.println();
44 }
45 
47 inline void println() {
48  Serial.println();
49 }
50 
51 }
52 }
53 
54 #endif