Skip to content

Commit 6018b14

Browse files
committed
Logging can be removed from executable by not setting LOGGING symbol.
1 parent cf25b49 commit 6018b14

File tree

4 files changed

+1151
-916
lines changed

4 files changed

+1151
-916
lines changed

Logger.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include "Logger.h"
22

3-
#ifdef DEBUG
3+
#ifdef LOGGING
44
Level Logger::log_threshold = WARN;
55
#endif // DEBUG

Logger.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@
77

88
enum Level {DEBUG, INFO, WARN, ERROR, FATAL};
99

10-
#ifdef DEBUG
10+
#ifdef LOGGING
1111
class Logger {
1212
public:
1313
static Level log_threshold;
1414
};
15-
#endif // DEBUG
15+
#endif // LOGGING
1616

1717
inline
1818
void print_log_level(const Level& level)
1919
{
20-
#ifdef DEBUG
20+
#ifdef LOGGING
2121
Serial.print(level);
2222

2323
switch (level) {
@@ -33,20 +33,20 @@ void print_log_level(const Level& level)
3333
inline
3434
void print_log_levels()
3535
{
36-
#ifdef DEBUG
36+
#ifdef LOGGING
3737
for (uint8_t level=DEBUG; level<FATAL; level+=1) {
3838
print_log_level((Level)level);
3939
Serial.print(", ");
4040
}
4141
print_log_level(FATAL);
4242
Serial.println("");
43-
#endif //DEBUG
43+
#endif // DEBUG
4444
}
4545

4646

4747
inline void log(const Level& level, const char *__fmt, ...)
4848
{
49-
#ifdef DEBUG
49+
#ifdef LOGGING
5050
if (Logger::log_threshold <= level) {
5151
Serial.print(millis());
5252
Serial.print(" ");
@@ -62,7 +62,7 @@ inline void log(const Level& level, const char *__fmt, ...)
6262

6363
Serial.println(buf);
6464
}
65-
#endif // DEBUG
65+
#endif // LOGGING
6666
}
6767

6868

Manager.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,16 @@ void Manager::handle_serial_commands()
6969
}
7070
break;
7171
case 'v':
72-
#ifdef DEBUG
72+
#ifdef LOGGING
7373
Serial.println("ACK enter log level:");
7474
print_log_levels();
7575
Logger::log_threshold = (Level)utils::read_uint32_from_serial();
7676
Serial.print("ACK Log level set to ");
7777
print_log_level(Logger::log_threshold);
7878
Serial.println("");
7979
#else
80-
Serial.println("NAK debugging disabled!");
81-
#endif // DEBUG
80+
Serial.println("NAK logging disabled!");
81+
#endif // LOGGING
8282
break;
8383
case 'k': print_packets = ONLY_KNOWN; Serial.println("ACK only print data from known transmitters"); break;
8484
case 'u': print_packets = ALL_VALID; Serial.println("ACK print all valid packets"); break;

0 commit comments

Comments
 (0)