Skip to content

Commit 8253f4d

Browse files
authored
Deprecate logDebug and logDebugf. (#125)
* Deprecate logDebug and logDebugf. These are wrappers around NoteDebug, which is really intended for internal note-c usage only. As such, we don't want users calling these functions. * Tweak test script to not warn on deprecated function declarations.
1 parent c3a915f commit 8253f4d

File tree

3 files changed

+36
-10
lines changed

3 files changed

+36
-10
lines changed

src/Notecard.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,31 +309,44 @@ void Notecard::deleteResponse(J *rsp)
309309

310310
/**************************************************************************/
311311
/*!
312+
@deprecated NoteDebug, which this function wraps, should be treated as an
313+
internal Notecard logging function, used only by the library itself
314+
(note-arduino and note-c) and not its users.
312315
@brief Write a message to the serial debug stream.
313316
@param message
314317
A string to log to the serial debug stream.
315318
*/
316319
/**************************************************************************/
317-
void Notecard::logDebug(const char *message)
320+
NOTE_ARDUINO_DEPRECATED void Notecard::logDebug(const char *message)
318321
{
322+
#ifdef NOTE_ARDUINO_NO_DEPRECATED_ATTR
323+
NOTE_C_LOG_WARN("logDebug is deprecated.")
324+
#endif
319325
NoteDebug(message);
320326
}
321327

322328
/**************************************************************************/
323329
/*!
330+
@deprecated NoteDebug, which this function wraps, should be treated as an
331+
internal Notecard logging function, used only by the library itself
332+
(note-arduino and note-c) and not its users.
324333
@brief Write a formatted message to the serial debug stream.
325334
@param format
326335
A format string to log to the serial debug stream.
327336
@param ... one or more values to interpolate into the format string.
328337
*/
329338
/**************************************************************************/
330-
void Notecard::logDebugf(const char *format, ...)
339+
NOTE_ARDUINO_DEPRECATED void Notecard::logDebugf(const char *format, ...)
331340
{
332341
char message[256];
333342
va_list args;
334343
va_start(args, format);
335344
vsnprintf(message, sizeof(message), format, args);
336345
va_end(args);
346+
347+
#ifdef NOTE_ARDUINO_NO_DEPRECATED_ATTR
348+
NOTE_C_LOG_WARN("logDebugf is deprecated.")
349+
#endif
337350
NoteDebug(message);
338351
}
339352

src/Notecard.h

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,15 @@
4545
#include "mock/mock-parameters.hpp"
4646
#endif
4747

48+
#if defined(__GNUC__) | defined(__clang__)
49+
#define NOTE_ARDUINO_DEPRECATED __attribute__((__deprecated__))
50+
#elif defined(_MSC_VER)
51+
#define NOTE_ARDUINO_DEPRECATED __declspec(deprecated)
52+
#else
53+
#define NOTE_ARDUINO_DEPRECATED
54+
#define NOTE_ARDUINO_NO_DEPRECATED_ATTR
55+
#endif // __GNUC__ || __clang__
56+
4857
/**************************************************************************/
4958
/*!
5059
@brief Class that stores state and functions for interacting with the
@@ -83,8 +92,8 @@ class Notecard
8392
}
8493
bool debugSyncStatus(int pollFrequencyMs, int maxLevel);
8594
void deleteResponse(J *rsp);
86-
void logDebug(const char *message);
87-
void logDebugf(const char *format, ...);
95+
NOTE_ARDUINO_DEPRECATED void logDebug(const char *message);
96+
NOTE_ARDUINO_DEPRECATED void logDebugf(const char *format, ...);
8897
J *newCommand(const char *request);
8998
J *newRequest(const char *request);
9099
J *requestAndResponse(J *req);

test/run_all_tests.sh

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,13 @@ all_tests_result=0
1111
# host machine is running Fedora. See https://stackoverflow.com/a/75293014.
1212
ulimit -n 1024
1313

14+
# Note that we use -Wno-deprecated-declarations in the compilation commands
15+
# below because we have deprecated some note-arduino functions (e.g. logDebug),
16+
# but we still have unit tests for them.
17+
1418
if [ 0 -eq $all_tests_result ]; then
1519
echo && echo -e "${YELLOW}Compiling and running Notecard Test Suite...${DEFAULT}"
16-
g++ -fprofile-arcs -ftest-coverage -Wall -Wextra -Werror -Wpedantic -std=c++11 -O0 -g \
20+
g++ -fprofile-arcs -ftest-coverage -Wall -Wextra -Werror -Wpedantic -Wno-deprecated-declarations -std=c++11 -O0 -g \
1721
src/Notecard.cpp \
1822
test/Notecard.test.cpp \
1923
test/mock/mock-arduino.cpp \
@@ -43,7 +47,7 @@ fi
4347

4448
if [ 0 -eq $all_tests_result ]; then
4549
echo && echo -e "${YELLOW}Compiling and running NoteI2c_Arduino Test Suite (no flags)...${DEFAULT}"
46-
g++ -fprofile-arcs -ftest-coverage -Wall -Wextra -Werror -Wpedantic -std=c++11 -O0 -g \
50+
g++ -fprofile-arcs -ftest-coverage -Wall -Wextra -Werror -Wpedantic -Wno-deprecated-declarations -std=c++11 -O0 -g \
4751
src/NoteI2c_Arduino.cpp \
4852
test/NoteI2c_Arduino.test.cpp \
4953
test/mock/mock-arduino.cpp \
@@ -67,7 +71,7 @@ fi
6771

6872
if [ 0 -eq $all_tests_result ]; then
6973
echo && echo -e "${YELLOW}Compiling and running NoteI2c_Arduino Test Suite (-DWIRE_HAS_END)...${DEFAULT}"
70-
g++ -fprofile-arcs -ftest-coverage -Wall -Wextra -Werror -Wpedantic -std=c++11 -O0 -g \
74+
g++ -fprofile-arcs -ftest-coverage -Wall -Wextra -Werror -Wpedantic -Wno-deprecated-declarations -std=c++11 -O0 -g \
7175
src/NoteI2c_Arduino.cpp \
7276
test/NoteI2c_Arduino.test.cpp \
7377
test/mock/mock-arduino.cpp \
@@ -92,7 +96,7 @@ fi
9296

9397
if [ 0 -eq $all_tests_result ]; then
9498
echo && echo -e "${YELLOW}Compiling and running NoteLog_Arduino Test Suite...${DEFAULT}"
95-
g++ -fprofile-arcs -ftest-coverage -Wall -Wextra -Werror -Wpedantic -std=c++11 -O0 -g \
99+
g++ -fprofile-arcs -ftest-coverage -Wall -Wextra -Werror -Wpedantic -Wno-deprecated-declarations -std=c++11 -O0 -g \
96100
src/NoteLog_Arduino.cpp \
97101
test/NoteLog_Arduino.test.cpp \
98102
test/mock/mock-arduino.cpp \
@@ -116,7 +120,7 @@ fi
116120

117121
if [ 0 -eq $all_tests_result ]; then
118122
echo && echo -e "${YELLOW}Compiling and running NoteSerial_Arduino Test Suite...${DEFAULT}"
119-
g++ -fprofile-arcs -ftest-coverage -Wall -Wextra -Werror -Wpedantic -std=c++11 -O0 -g \
123+
g++ -fprofile-arcs -ftest-coverage -Wall -Wextra -Werror -Wpedantic -Wno-deprecated-declarations -std=c++11 -O0 -g \
120124
src/NoteSerial_Arduino.cpp \
121125
test/NoteSerial_Arduino.test.cpp \
122126
test/mock/mock-arduino.cpp \
@@ -140,7 +144,7 @@ fi
140144

141145
if [ 0 -eq $all_tests_result ]; then
142146
echo && echo -e "${YELLOW}Compiling and running NoteTxn_Arduino Test Suite...${DEFAULT}"
143-
g++ -fprofile-arcs -ftest-coverage -Wall -Wextra -Werror -Wpedantic -std=c++11 -O0 -g \
147+
g++ -fprofile-arcs -ftest-coverage -Wall -Wextra -Werror -Wpedantic -Wno-deprecated-declarations -std=c++11 -O0 -g \
144148
src/NoteTxn_Arduino.cpp \
145149
test/NoteTxn_Arduino.test.cpp \
146150
test/mock/mock-arduino.cpp \

0 commit comments

Comments
 (0)