Skip to content

Commit e86ee93

Browse files
committed
backport: fix build for debug levels DBG_WARN and less
1 parent efb197c commit e86ee93

File tree

1 file changed

+26
-19
lines changed

1 file changed

+26
-19
lines changed

src/MicroOcpp/Model/Diagnostics/DiagnosticsService.cpp

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// matth-x/MicroOcpp
2-
// Copyright Matthias Akstaller 2019 - 2023
2+
// Copyright Matthias Akstaller 2019 - 2024
33
// MIT License
44

55
#include <MicroOcpp/Model/Diagnostics/DiagnosticsService.h>
@@ -101,30 +101,37 @@ std::string DiagnosticsService::requestDiagnosticsUpload(const char *location, u
101101
}
102102

103103
#if MO_DBG_LEVEL >= MO_DL_INFO
104-
char dbuf [JSONDATE_LENGTH + 1] = {'\0'};
105-
char dbuf2 [JSONDATE_LENGTH + 1] = {'\0'};
106-
this->startTime.toJsonString(dbuf, JSONDATE_LENGTH + 1);
107-
this->stopTime.toJsonString(dbuf2, JSONDATE_LENGTH + 1);
108-
109-
MO_DBG_INFO("Scheduled Diagnostics upload!\n" \
110-
" location = %s\n" \
111-
" retries = %i" \
112-
", retryInterval = %u" \
113-
" startTime = %s\n" \
114-
" stopTime = %s",
115-
this->location.c_str(),
116-
this->retries,
117-
this->retryInterval,
118-
dbuf,
119-
dbuf2);
104+
{
105+
char dbuf [JSONDATE_LENGTH + 1] = {'\0'};
106+
char dbuf2 [JSONDATE_LENGTH + 1] = {'\0'};
107+
this->startTime.toJsonString(dbuf, JSONDATE_LENGTH + 1);
108+
this->stopTime.toJsonString(dbuf2, JSONDATE_LENGTH + 1);
109+
110+
MO_DBG_INFO("Scheduled Diagnostics upload!\n" \
111+
" location = %s\n" \
112+
" retries = %i" \
113+
", retryInterval = %u" \
114+
" startTime = %s\n" \
115+
" stopTime = %s",
116+
this->location.c_str(),
117+
this->retries,
118+
this->retryInterval,
119+
dbuf,
120+
dbuf2);
121+
}
120122
#endif
121123

122124
nextTry = context.getModel().getClock().now();
123125
nextTry += 5; //wait for 5s before upload
124126
uploadIssued = false;
125127

126-
nextTry.toJsonString(dbuf, JSONDATE_LENGTH + 1);
127-
MO_DBG_DEBUG("Initial try at %s", dbuf);
128+
#if MO_DBG_LEVEL >= MO_DL_DEBUG
129+
{
130+
char dbuf [JSONDATE_LENGTH + 1] = {'\0'};
131+
nextTry.toJsonString(dbuf, JSONDATE_LENGTH + 1);
132+
MO_DBG_DEBUG("Initial try at %s", dbuf);
133+
}
134+
#endif
128135

129136
std::string fileName;
130137
if (refreshFilename) {

0 commit comments

Comments
 (0)