Skip to content

Commit 1cd099e

Browse files
committed
Add public print method that takes va_list instead of varargs
1 parent 6ebae16 commit 1cd099e

File tree

2 files changed

+12
-16
lines changed

2 files changed

+12
-16
lines changed

src/Arduino_DebugUtils.cpp

+11-15
Original file line numberDiff line numberDiff line change
@@ -91,22 +91,23 @@ void Arduino_DebugUtils::timestampOff() {
9191

9292
void Arduino_DebugUtils::print(int const debug_level, const char * fmt, ...)
9393
{
94-
if (!shouldPrint(debug_level))
95-
return;
96-
97-
if (_print_debug_label)
98-
printDebugLabel(debug_level);
94+
va_list args;
95+
va_start(args, fmt);
96+
print(debug_level, fmt, args);
97+
va_end(args);
98+
}
9999

100-
if (_timestamp_on)
101-
printTimestamp();
100+
void Arduino_DebugUtils::print(int const debug_level, const __FlashStringHelper * fmt, ...)
101+
{
102+
String fmt_str(fmt);
102103

103104
va_list args;
104105
va_start(args, fmt);
105-
vPrint(fmt, args);
106+
print(debug_level, fmt_str.c_str(), args);
106107
va_end(args);
107108
}
108109

109-
void Arduino_DebugUtils::print(int const debug_level, const __FlashStringHelper * fmt, ...)
110+
void Arduino_DebugUtils::print(int const debug_level, const char * fmt, va_list args)
110111
{
111112
if (!shouldPrint(debug_level))
112113
return;
@@ -117,12 +118,7 @@ void Arduino_DebugUtils::print(int const debug_level, const __FlashStringHelper
117118
if (_timestamp_on)
118119
printTimestamp();
119120

120-
String fmt_str(fmt);
121-
122-
va_list args;
123-
va_start(args, fmt);
124-
vPrint(fmt_str.c_str(), args);
125-
va_end(args);
121+
vPrint(fmt, args);
126122
}
127123

128124
/******************************************************************************

src/Arduino_DebugUtils.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class Arduino_DebugUtils {
6969

7070
void print(int const debug_level, const char * fmt, ...);
7171
void print(int const debug_level, const __FlashStringHelper * fmt, ...);
72-
72+
void print(int const debug_level, const char * fmt, va_list args);
7373

7474
private:
7575

0 commit comments

Comments
 (0)