Skip to content

Commit 53465b4

Browse files
authored
optimize log functions (#304)
* move logging to own compilation unit * remove obsolete (void)0 statements after MO_DBG * update changelog * optimize MO_CUSTOM_CONSOLE method
1 parent a36e6a4 commit 53465b4

29 files changed

+108
-112
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
- Ignore UnlockConnector when handler not set ([#271](https://github.com/matth-x/MicroOcpp/pull/271))
4040
- Reject ChargingProfile if unit not supported ([#271](https://github.com/matth-x/MicroOcpp/pull/271))
4141
- Fix building with debug level warn and error
42+
- Reduce debug output FW size overhead ([#304](https://github.com/matth-x/MicroOcpp/pull/304))
4243
- Fix transaction freeze in offline mode ([#279](https://github.com/matth-x/MicroOcpp/pull/279), [#287](https://github.com/matth-x/MicroOcpp/pull/287))
4344
- Fix compilation error caused by `PRId32` ([#279](https://github.com/matth-x/MicroOcpp/pull/279))
4445
- Don't load FW-mngt. module when no handlers set ([#271](https://github.com/matth-x/MicroOcpp/pull/271))

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ set(MO_SRC
6363
src/MicroOcpp/Operations/InstallCertificate.cpp
6464
src/MicroOcpp/Operations/UnlockConnector.cpp
6565
src/MicroOcpp/Operations/UpdateFirmware.cpp
66+
src/MicroOcpp/Debug.cpp
6667
src/MicroOcpp/Platform.cpp
6768
src/MicroOcpp/Core/SimpleRequestFactory.cpp
6869
src/MicroOcpp/Core/OperationRegistry.cpp

src/MicroOcpp.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,6 @@ bool endTransaction(const char *idTag, const char *reason, unsigned int connecto
445445
res = endTransaction_authorized(idTag, reason, connectorId);
446446
} else {
447447
MO_DBG_INFO("endTransaction: idTag doesn't match");
448-
(void)0;
449448
}
450449
}
451450
return res;
@@ -977,7 +976,6 @@ void setCertificateStore(std::unique_ptr<MicroOcpp::CertificateStore> certStore)
977976
certService->setCertificateStore(std::move(certStore));
978977
} else {
979978
MO_DBG_ERR("OOM");
980-
(void)0;
981979
}
982980
}
983981
#endif //MO_ENABLE_CERT_MGMT

src/MicroOcpp/Core/Configuration.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ ConfigurationContainer *declareContainer(const char *filename, bool accessible)
7979

8080
if (container->isAccessible() != accessible) {
8181
MO_DBG_ERR("%s: conflicting accessibility declarations (expect %s)", filename, container->isAccessible() ? "accessible" : "inaccessible");
82-
(void)0;
8382
}
8483

8584
return container.get();
@@ -95,7 +94,6 @@ std::shared_ptr<Configuration> loadConfiguration(TConfig type, const char *key,
9594
}
9695
if (container->isAccessible() != accessible) {
9796
MO_DBG_ERR("conflicting accessibility for %s", key);
98-
(void)0;
9997
}
10098
container->loadStaticKey(*config.get(), key);
10199
return config;

src/MicroOcpp/Core/ConfigurationContainerFlash.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,6 @@ class ConfigurationContainerFlash : public ConfigurationContainer {
181181
}
182182
} else {
183183
MO_DBG_ERR("OOM: %s", key);
184-
(void)0;
185184
}
186185
}
187186

src/MicroOcpp/Core/FilesystemUtils.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ bool FilesystemUtils::remove_if(std::shared_ptr<FilesystemAdapter> filesystem, s
134134

135135
if (ret != 0) {
136136
MO_DBG_ERR("ftw_root: %i", ret);
137-
(void)0;
138137
}
139138

140139
return ret == 0;

src/MicroOcpp/Core/FtpMbedTLS.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,6 @@ void FtpTransferMbedTLS::send_cmd(const char *cmd, const char *arg, bool disable
411411
MO_DBG_DEBUG("SEND: %s %s",
412412
cmd,
413413
!strncmp((char*) cmd, "PASS", strlen("PASS")) ? "***" : arg ? (char*) arg : "");
414-
(void)0;
415414
}
416415

417416
int ret = -1;
@@ -647,7 +646,6 @@ void FtpTransferMbedTLS::process_ctrl() {
647646
return;
648647
} else if (!strncmp("200", line, 3)) { //PBSZ -> 0 and PROT -> P accepted
649648
MO_DBG_INFO("PBSZ/PROT success: %s", line);
650-
(void)0;
651649
} else if (!strncmp("221", line, 3)) { // Server Goodbye
652650
MO_DBG_DEBUG("closing ctrl connection");
653651
close_ctrl();

src/MicroOcpp/Core/Request.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,6 @@ bool Request::restore(std::unique_ptr<StoredOperationHandler> opStorage, Model *
308308
}
309309
} else {
310310
MO_DBG_ERR("cannot set unique msgID counter");
311-
(void)0;
312311
//skip this step but don't abort restore
313312
}
314313

@@ -330,10 +329,8 @@ bool Request::restore(std::unique_ptr<StoredOperationHandler> opStorage, Model *
330329

331330
if (success) {
332331
MO_DBG_DEBUG("restored opNr %i: %s", opStore->getOpNr(), operation->getOperationType());
333-
(void)0;
334332
} else {
335333
MO_DBG_ERR("restore opNr %i error", opStore->getOpNr());
336-
(void)0;
337334
}
338335

339336
return success;

src/MicroOcpp/Core/RequestQueue.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,10 +242,8 @@ void RequestQueue::receiveResponse(JsonArray json) {
242242
//didn't find matching Request
243243
if (json[0] == MESSAGE_TYPE_CALLERROR) {
244244
MO_DBG_DEBUG("Received CALLERROR did not abort a pending operation");
245-
(void)0;
246245
} else {
247246
MO_DBG_WARN("Received response doesn't match any pending operation");
248-
(void)0;
249247
}
250248
}
251249
}

src/MicroOcpp/Core/RequestQueueStorageStrategy.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ void VolatileRequestQueue::push_back(std::unique_ptr<Request> op) {
4242

4343
if (queue.size() >= MO_OPERATIONCACHE_MAXSIZE) {
4444
MO_DBG_WARN("unsafe number of cached operations");
45-
(void)0;
4645
}
4746

4847
queue.push_back(std::move(op));

0 commit comments

Comments
 (0)