Skip to content

Commit ac97209

Browse files
committed
Dropping namespace 'impl' since instantiation name is different from class name
1 parent b084c26 commit ac97209

File tree

2 files changed

+70
-94
lines changed

2 files changed

+70
-94
lines changed

Diff for: src/Arduino_DebugUtils.cpp

+54-66
Original file line numberDiff line numberDiff line change
@@ -22,86 +22,74 @@
2222
#include "Arduino_DebugUtils.h"
2323

2424
/******************************************************************************
25-
NAMESPACE
25+
CONSTANTS
2626
******************************************************************************/
2727

28-
namespace impl {
28+
static int const DEFAULT_DEBUG_LEVEL = DEBUG_LVL_INFO;
29+
static Stream * DEFAULT_OUTPUT_STREAM = &Serial;
2930

30-
/******************************************************************************
31-
CONSTANTS
32-
******************************************************************************/
33-
34-
static int const DEFAULT_DEBUG_LEVEL = DEBUG_LVL_INFO;
35-
static Stream * DEFAULT_OUTPUT_STREAM = &Serial;
36-
37-
/******************************************************************************
38-
CTOR/DTOR
39-
******************************************************************************/
40-
41-
Arduino_DebugUtils::Arduino_DebugUtils() {
42-
timestampOff();
43-
setDebugLevel(DEFAULT_DEBUG_LEVEL);
44-
setDebugOutputStream(DEFAULT_OUTPUT_STREAM);
45-
}
46-
47-
/******************************************************************************
48-
PUBLIC MEMBER FUNCTIONS
49-
******************************************************************************/
50-
51-
void Arduino_DebugUtils::setDebugLevel(int const debug_level) {
52-
_debug_level = debug_level;
53-
}
31+
/******************************************************************************
32+
CTOR/DTOR
33+
******************************************************************************/
5434

55-
void Arduino_DebugUtils::setDebugOutputStream(Stream * stream) {
56-
_debug_output_stream = stream;
57-
}
35+
Arduino_DebugUtils::Arduino_DebugUtils() {
36+
timestampOff();
37+
setDebugLevel(DEFAULT_DEBUG_LEVEL);
38+
setDebugOutputStream(DEFAULT_OUTPUT_STREAM);
39+
}
5840

59-
void Arduino_DebugUtils::timestampOn() {
60-
_timestamp_on = true;
61-
}
62-
63-
void Arduino_DebugUtils::timestampOff() {
64-
_timestamp_on = false;
65-
}
41+
/******************************************************************************
42+
PUBLIC MEMBER FUNCTIONS
43+
******************************************************************************/
6644

67-
void Arduino_DebugUtils::print(int const debug_level, const char * fmt, ...) {
68-
if (debug_level >= DEBUG_LVL_ERROR &&
69-
debug_level <= DEBUG_LVL_VERBOSE &&
70-
debug_level <= _debug_level) {
71-
if (_timestamp_on) {
72-
char timestamp[20];
73-
snprintf(timestamp, 20, "[ %lu ] ", millis());
74-
_debug_output_stream->print(timestamp);
75-
}
76-
77-
va_list args;
78-
va_start(args, fmt);
79-
vPrint(fmt, args);
80-
va_end(args);
45+
void Arduino_DebugUtils::setDebugLevel(int const debug_level) {
46+
_debug_level = debug_level;
47+
}
48+
49+
void Arduino_DebugUtils::setDebugOutputStream(Stream * stream) {
50+
_debug_output_stream = stream;
51+
}
52+
53+
void Arduino_DebugUtils::timestampOn() {
54+
_timestamp_on = true;
55+
}
56+
57+
void Arduino_DebugUtils::timestampOff() {
58+
_timestamp_on = false;
59+
}
60+
61+
void Arduino_DebugUtils::print(int const debug_level, const char * fmt, ...) {
62+
if (debug_level >= DEBUG_LVL_ERROR &&
63+
debug_level <= DEBUG_LVL_VERBOSE &&
64+
debug_level <= _debug_level) {
65+
if (_timestamp_on) {
66+
char timestamp[20];
67+
snprintf(timestamp, 20, "[ %lu ] ", millis());
68+
_debug_output_stream->print(timestamp);
8169
}
82-
}
8370

84-
/******************************************************************************
85-
PRIVATE MEMBER FUNCTIONS
86-
******************************************************************************/
87-
88-
void Arduino_DebugUtils::vPrint(char const * fmt, va_list args) {
89-
static size_t const MSG_BUF_SIZE = 120;
90-
char msg_buf[MSG_BUF_SIZE] = {0};
71+
va_list args;
72+
va_start(args, fmt);
73+
vPrint(fmt, args);
74+
va_end(args);
75+
}
76+
}
9177

92-
vsnprintf(msg_buf, MSG_BUF_SIZE, fmt, args);
78+
/******************************************************************************
79+
PRIVATE MEMBER FUNCTIONS
80+
******************************************************************************/
9381

94-
_debug_output_stream->println(msg_buf);
95-
}
82+
void Arduino_DebugUtils::vPrint(char const * fmt, va_list args) {
83+
static size_t const MSG_BUF_SIZE = 120;
84+
char msg_buf[MSG_BUF_SIZE] = {0};
9685

97-
/******************************************************************************
98-
NAMESPACE
99-
******************************************************************************/
86+
vsnprintf(msg_buf, MSG_BUF_SIZE, fmt, args);
10087

101-
} /* impl */
88+
_debug_output_stream->println(msg_buf);
89+
}
10290

10391
/******************************************************************************
10492
CLASS INSTANTIATION
10593
******************************************************************************/
10694

107-
impl::Arduino_DebugUtils Debug;
95+
Arduino_DebugUtils Debug;

Diff for: src/Arduino_DebugUtils.h

+16-28
Original file line numberDiff line numberDiff line change
@@ -38,50 +38,38 @@ static int const DEBUG_LVL_DEBUG = 3;
3838
static int const DEBUG_LVL_VERBOSE = 4;
3939

4040
/******************************************************************************
41-
NAMESPACE
41+
CLASS DECLARATION
4242
******************************************************************************/
4343

44-
namespace impl {
44+
class Arduino_DebugUtils {
4545

46-
/******************************************************************************
47-
CLASS DECLARATION
48-
******************************************************************************/
46+
public:
4947

50-
class Arduino_DebugUtils {
48+
Arduino_DebugUtils();
5149

52-
public:
50+
void setDebugLevel(int const debug_level);
51+
void setDebugOutputStream(Stream * stream);
5352

54-
Arduino_DebugUtils();
53+
void timestampOn();
54+
void timestampOff();
5555

56-
void setDebugLevel(int const debug_level);
57-
void setDebugOutputStream(Stream * stream);
56+
void print(int const debug_level, const char * fmt, ...);
5857

59-
void timestampOn();
60-
void timestampOff();
6158

62-
void print(int const debug_level, const char * fmt, ...);
59+
private:
6360

61+
bool _timestamp_on;
62+
int _debug_level;
63+
Stream * _debug_output_stream;
6464

65-
private:
65+
void vPrint(char const * fmt, va_list args);
6666

67-
bool _timestamp_on;
68-
int _debug_level;
69-
Stream * _debug_output_stream;
70-
71-
void vPrint(char const * fmt, va_list args);
72-
73-
};
74-
75-
/******************************************************************************
76-
NAMESPACE
77-
******************************************************************************/
78-
79-
} /* impl */
67+
};
8068

8169
/******************************************************************************
8270
EXTERN
8371
******************************************************************************/
8472

85-
extern impl::Arduino_DebugUtils Debug;
73+
extern Arduino_DebugUtils Debug;
8674

8775
#endif /* ARDUINO_DEBUG_UTILS_H_ */

0 commit comments

Comments
 (0)