AceTime
1.1.2
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.
src
ace_time
common
logging.h
1
/*
2
* MIT License
3
* Copyright (c) 2018 Brian T. Park
4
*/
5
6
/*
7
* Implement logging::printf() that accept formatting strings like printf(). I
8
* finally got tired of writing multiple lines of SERIAL_PORT_MONITOR.print()
9
* for debugging.
10
*
11
* NOTE: These *must* be implemented as inline function to allow the compiler
12
* to remove unused functions from the binary. For some reason, on AVR, ESP8266
13
* and ESP32 compilers, link-time-optimization does not seem to work well. If
14
* these functions are defined in a .cpp file, they are included in the binary,
15
* even if they are not reference at all by anything. This causes the binary to
16
* be about 700 (AVR) to 1000 (ESP32) bytes larger in flash memory. Being
17
* inlined here means that <Arduino.h> must be included here, which can cause
18
* some problems in files that try to clobber macros defined in <Ardhino.h>.
19
*/
20
21
#ifndef ACE_TIME_COMMON_LOGGING_H
22
#define ACE_TIME_COMMON_LOGGING_H
23
24
#include <stdarg.h>
25
#include <Arduino.h>
26
27
namespace
ace_time {
28
namespace
logging {
29
30
static
const
int
BUF_SIZE = 192;
31
32
inline
void
vprintf(
const
char
*fmt, va_list args) {
33
char
buf[BUF_SIZE];
34
vsnprintf(buf, BUF_SIZE, fmt, args);
35
SERIAL_PORT_MONITOR.print(buf);
36
}
37
42
inline
void
printf(
const
char
* fmt, ...) {
43
va_list args;
44
va_start(args, fmt);
45
vprintf(fmt, args);
46
va_end(args);
47
}
48
49
}
50
}
51
52
#endif
Generated by
1.8.17