Skip to content

Commit a35fbd4

Browse files
committed
Fixing some bugs within ArduinoDebugUtils
1 parent 4081de2 commit a35fbd4

File tree

2 files changed

+48
-6
lines changed

2 files changed

+48
-6
lines changed

src/ArduinoDebugUtils.cpp

+27-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,20 @@
2121

2222
#include "ArduinoDebugUtils.h"
2323

24+
/******************************************************************************
25+
NAMESPACE
26+
******************************************************************************/
27+
28+
namespace impl
29+
{
30+
31+
/******************************************************************************
32+
CONSTANTS
33+
******************************************************************************/
34+
35+
static DebugLevel const DEFAULT_DEBUG_LEVEL = DebugLevel::Info;
36+
static Stream * DEFAULT_OUTPUT_STREAM = &Serial;
37+
2438
/******************************************************************************
2539
CTOR/DTOR
2640
******************************************************************************/
@@ -66,7 +80,7 @@ void ArduinoDebugUtils::debugPrint(DebugLevel const debug_level, const char * fm
6680
{
6781
char timestamp[20];
6882
snprintf(timestamp, 20, "[ %lu ] ", millis());
69-
debug_output_stream->print(timestamp);
83+
_debug_output_stream->print(timestamp);
7084
}
7185

7286
va_list args;
@@ -89,3 +103,15 @@ void ArduinoDebugUtils::vDebugPrint(char const * fmt, va_list args)
89103

90104
_debug_output_stream->println(msg_buf);
91105
}
106+
107+
/******************************************************************************
108+
NAMESPACE
109+
******************************************************************************/
110+
111+
} /* impl */
112+
113+
/******************************************************************************
114+
CLASS INSTANTIATION
115+
******************************************************************************/
116+
117+
impl::ArduinoDebugUtils ArduinoDebugUtils;

src/ArduinoDebugUtils.h

+21-5
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424

2525
#include <Arduino.h>
2626

27+
#include <stdarg.h>
28+
2729
/******************************************************************************
2830
TYPEDEF
2931
******************************************************************************/
@@ -37,6 +39,13 @@ enum class DebugLevel : int {
3739
Verbose = 4
3840
};
3941

42+
/******************************************************************************
43+
NAMESPACE
44+
******************************************************************************/
45+
46+
namespace impl
47+
{
48+
4049
/******************************************************************************
4150
CLASS DECLARATION
4251
******************************************************************************/
@@ -61,15 +70,22 @@ class ArduinoDebugUtils
6170

6271
bool _timestamp_on;
6372
DebugLevel _debug_level;
64-
Stream * _debug_output_stream = &Serial;
73+
Stream * _debug_output_stream;
6574

75+
void vDebugPrint(char const * fmt, va_list args);
6676

67-
static DebugLevel const DEFAULT_DEBUG_LEVEL = DebugLevel::Info;
68-
static Stream * DEFAULT_OUTPUT_STREAM = &Serial;
77+
};
6978

79+
/******************************************************************************
80+
NAMESPACE
81+
******************************************************************************/
7082

71-
void vDebugPrint(char const * fmt, va_list args);
83+
} /* impl */
7284

73-
};
85+
/******************************************************************************
86+
EXTERN
87+
******************************************************************************/
88+
89+
extern impl::ArduinoDebugUtils ArduinoDebugUtils;
7490

7591
#endif /* ARDUINO_DEBUG_UTILS_H_ */

0 commit comments

Comments
 (0)