From f88d0188bb7760a03f1e5365e4853b9f4b9f4eb4 Mon Sep 17 00:00:00 2001 From: john30 Date: Sun, 20 Nov 2016 11:54:49 +0100 Subject: [PATCH] better logging --- src/ebusd/main.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/ebusd/main.cpp b/src/ebusd/main.cpp index ede4d9d7..86a22fb4 100644 --- a/src/ebusd/main.cpp +++ b/src/ebusd/main.cpp @@ -655,10 +655,11 @@ static bool readTemplates(const string path, const string extension, bool availa return true; } result_t result = templates->readFromFile(path+"/_templates"+extension, verbose); - if (result == RESULT_OK) + if (result == RESULT_OK) { logInfo(lf_main, "read templates in %s", path.c_str()); - else - logError(lf_main, "error reading templates in %s: %s, %s", path.c_str(), getResultCode(result), templates->getLastError().c_str()); + } else { + logError(lf_main, "error reading templates in %s: %s, last error: %s", path.c_str(), getResultCode(result), templates->getLastError().c_str()); + } return templates; } @@ -724,12 +725,12 @@ void executeInstructions(MessageMap* messages, bool verbose) { result_t result = messages->resolveConditions(verbose); if (result != RESULT_OK) { - logError(lf_main, "error resolving conditions: %s, %s", getResultCode(result), messages->getLastError().c_str()); + logError(lf_main, "error resolving conditions: %s, last error: %s", getResultCode(result), messages->getLastError().c_str()); } ostringstream log; result = messages->executeInstructions(log, readMessage); if (result != RESULT_OK) { - logError(lf_main, "error executing instructions: %s, %s, %s", getResultCode(result), messages->getLastError().c_str(), log.str().c_str()); + logError(lf_main, "error executing instructions: %s, last error: %s, %s", getResultCode(result), messages->getLastError().c_str(), log.str().c_str()); } else if (verbose && log.tellp() > 0) { logInfo(lf_main, log.str().c_str()); } @@ -742,18 +743,19 @@ result_t loadConfigFiles(MessageMap* messages, bool verbose, bool denyRecursive) messages->clear(); globalTemplates.clear(); for (map::iterator it = templatesByPath.begin(); it != templatesByPath.end(); it++) { - if (it->second!=&globalTemplates) + if (it->second!=&globalTemplates) { delete it->second; + } it->second = NULL; } templatesByPath.clear(); result_t result = readConfigFiles(string(opt.configPath), ".csv", messages, (!opt.scanConfig || opt.checkConfig) && !denyRecursive, verbose); - if (result == RESULT_OK) + if (result == RESULT_OK) { logInfo(lf_main, "read config files"); - else - logError(lf_main, "error reading config files: %s, %s", getResultCode(result), messages->getLastError().c_str()); - + } else { + logError(lf_main, "error reading config files: %s, last error: %s", getResultCode(result), messages->getLastError().c_str()); + } executeInstructions(messages, verbose); return RESULT_OK; }