Replaced Logger usage with LOG_x (#548)
This commit is contained in:
committed by
GitHub
parent
ecad2248d9
commit
9d5993930d
@@ -3,11 +3,11 @@
|
||||
#include <Tactility/StringUtils.h>
|
||||
#include <Tactility/file/File.h>
|
||||
#include <Tactility/file/FileLock.h>
|
||||
#include <Tactility/Logger.h>
|
||||
#include <tactility/log.h>
|
||||
|
||||
namespace tt::file {
|
||||
|
||||
static const auto LOGGER = Logger("PropertiesFile");
|
||||
constexpr auto* TAG = "PropertiesFile";
|
||||
|
||||
bool getKeyValuePair(const std::string& input, std::string& key, std::string& value) {
|
||||
auto index = input.find('=');
|
||||
@@ -22,7 +22,7 @@ bool getKeyValuePair(const std::string& input, std::string& key, std::string& va
|
||||
bool loadPropertiesFile(const std::string& filePath, std::function<void(const std::string& key, const std::string& value)> callback) {
|
||||
// Reading properties is a common operation; make this debug-level to avoid
|
||||
// flooding the serial console under frequent polling.
|
||||
LOGGER.debug("Reading properties file {}", filePath);
|
||||
LOG_D(TAG, "Reading properties file %s", filePath.c_str());
|
||||
uint16_t line_count = 0;
|
||||
std::string key_prefix = "";
|
||||
// Malformed lines are skipped, valid lines are loaded and callback is called
|
||||
@@ -40,7 +40,7 @@ bool loadPropertiesFile(const std::string& filePath, std::function<void(const st
|
||||
std::string trimmed_value = string::trim(value, " \t");
|
||||
callback(trimmed_key, trimmed_value);
|
||||
} else {
|
||||
LOGGER.error("Failed to parse line {} of {} (skipped)", line_count, filePath);
|
||||
LOG_E(TAG, "Failed to parse line %d of %s (skipped)", line_count, filePath.c_str());
|
||||
// Continue loading other lines
|
||||
}
|
||||
}
|
||||
@@ -57,11 +57,11 @@ bool loadPropertiesFile(const std::string& filePath, std::map<std::string, std::
|
||||
bool savePropertiesFile(const std::string& filePath, const std::map<std::string, std::string>& properties) {
|
||||
bool result = false;
|
||||
getLock(filePath)->withLock([&result, filePath, &properties] {
|
||||
LOGGER.info("Saving properties file {}", filePath);
|
||||
LOG_I(TAG, "Saving properties file %s", filePath.c_str());
|
||||
|
||||
FILE* file = fopen(filePath.c_str(), "w");
|
||||
if (file == nullptr) {
|
||||
LOGGER.error("Failed to open {}", filePath);
|
||||
LOG_E(TAG, "Failed to open %s", filePath.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user