@@ -60,36 +60,32 @@ void Arduino_DebugUtils::timestampOff() {
60
60
61
61
void Arduino_DebugUtils::print (int const debug_level, const char * fmt, ...)
62
62
{
63
- if (debug_level >= DBG_ERROR &&
64
- debug_level <= DBG_VERBOSE &&
65
- debug_level <= _debug_level)
66
- {
67
- if (_timestamp_on)
68
- printTimestamp ();
69
-
70
- va_list args;
71
- va_start (args, fmt);
72
- vPrint (fmt, args);
73
- va_end (args);
74
- }
63
+ if (!shouldPrint (debug_level))
64
+ return ;
65
+
66
+ if (_timestamp_on)
67
+ printTimestamp ();
68
+
69
+ va_list args;
70
+ va_start (args, fmt);
71
+ vPrint (fmt, args);
72
+ va_end (args);
75
73
}
76
74
77
75
void Arduino_DebugUtils::print (int const debug_level, const __FlashStringHelper * fmt, ...)
78
76
{
79
- if (debug_level >= DBG_ERROR &&
80
- debug_level <= DBG_VERBOSE &&
81
- debug_level <= _debug_level)
82
- {
83
- if (_timestamp_on)
84
- printTimestamp ();
85
-
86
- String fmt_str (fmt);
87
-
88
- va_list args;
89
- va_start (args, fmt_str.c_str ());
90
- vPrint (fmt_str.c_str (), args);
91
- va_end (args);
92
- }
77
+ if (!shouldPrint (debug_level))
78
+ return ;
79
+
80
+ if (_timestamp_on)
81
+ printTimestamp ();
82
+
83
+ String fmt_str (fmt);
84
+
85
+ va_list args;
86
+ va_start (args, fmt_str.c_str ());
87
+ vPrint (fmt_str.c_str (), args);
88
+ va_end (args);
93
89
}
94
90
95
91
/* *****************************************************************************
@@ -112,6 +108,11 @@ void Arduino_DebugUtils::printTimestamp()
112
108
_debug_output_stream->print (timestamp);
113
109
}
114
110
111
+ bool Arduino_DebugUtils::shouldPrint (int const debug_level) const
112
+ {
113
+ return ((debug_level >= DBG_ERROR) && (debug_level <= DBG_VERBOSE) && (debug_level <= _debug_level));
114
+ }
115
+
115
116
/* *****************************************************************************
116
117
CLASS INSTANTIATION
117
118
******************************************************************************/
0 commit comments