Replaced Logger usage with LOG_x (#548)
This commit is contained in:
committed by
GitHub
parent
ecad2248d9
commit
9d5993930d
@@ -1,25 +1,26 @@
|
||||
#include <Tactility/file/ObjectFile.h>
|
||||
#include <Tactility/Logger.h>
|
||||
#include <Tactility/service/gps/GpsService.h>
|
||||
#include <Tactility/service/ServicePaths.h>
|
||||
|
||||
#include <cstring>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <tactility/log.h>
|
||||
|
||||
using tt::hal::gps::GpsDevice;
|
||||
|
||||
namespace tt::service::gps {
|
||||
|
||||
static const auto LOGGER = Logger("GpsService");
|
||||
constexpr auto* TAG = "GpsService";
|
||||
|
||||
bool GpsService::getConfigurationFilePath(std::string& output) const {
|
||||
if (paths == nullptr) {
|
||||
LOGGER.error("Can't add configuration: service not started");
|
||||
LOG_E(TAG, "Can't add configuration: service not started");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!file::findOrCreateDirectory(paths->getUserDataDirectory(), 0777)) {
|
||||
LOGGER.error("Failed to find or create path {}", paths->getUserDataDirectory());
|
||||
LOG_E(TAG, "Failed to find or create path %s", paths->getUserDataDirectory().c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -35,21 +36,21 @@ bool GpsService::getGpsConfigurations(std::vector<hal::gps::GpsConfiguration>& c
|
||||
|
||||
// If file does not exist, return empty list
|
||||
if (access(path.c_str(), F_OK) != 0) {
|
||||
LOGGER.warn("No configurations (file not found: {})", path);
|
||||
LOG_W(TAG, "No configurations (file not found: %s)", path.c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
LOGGER.info("Reading configuration file {}", path);
|
||||
LOG_I(TAG, "Reading configuration file %s", path.c_str());
|
||||
auto reader = file::ObjectFileReader(path, sizeof(hal::gps::GpsConfiguration));
|
||||
if (!reader.open()) {
|
||||
LOGGER.error("Failed to open configuration file");
|
||||
LOG_E(TAG, "Failed to open configuration file");
|
||||
return false;
|
||||
}
|
||||
|
||||
hal::gps::GpsConfiguration configuration;
|
||||
while (reader.hasNext()) {
|
||||
if (!reader.readNext(&configuration)) {
|
||||
LOGGER.error("Failed to read configuration");
|
||||
LOG_E(TAG, "Failed to read configuration");
|
||||
reader.close();
|
||||
return false;
|
||||
} else {
|
||||
@@ -68,12 +69,12 @@ bool GpsService::addGpsConfiguration(hal::gps::GpsConfiguration configuration) {
|
||||
|
||||
auto appender = file::ObjectFileWriter(path, sizeof(hal::gps::GpsConfiguration), 1, true);
|
||||
if (!appender.open()) {
|
||||
LOGGER.error("Failed to open/create configuration file");
|
||||
LOG_E(TAG, "Failed to open/create configuration file");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!appender.write(&configuration)) {
|
||||
LOGGER.error("Failed to add configuration");
|
||||
LOG_E(TAG, "Failed to add configuration");
|
||||
appender.close();
|
||||
return false;
|
||||
}
|
||||
@@ -90,7 +91,7 @@ bool GpsService::removeGpsConfiguration(hal::gps::GpsConfiguration configuration
|
||||
|
||||
std::vector<hal::gps::GpsConfiguration> configurations;
|
||||
if (!getGpsConfigurations(configurations)) {
|
||||
LOGGER.error("Failed to get gps configurations");
|
||||
LOG_E(TAG, "Failed to get gps configurations");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -102,7 +103,7 @@ bool GpsService::removeGpsConfiguration(hal::gps::GpsConfiguration configuration
|
||||
|
||||
auto writer = file::ObjectFileWriter(path, sizeof(hal::gps::GpsConfiguration), 1, false);
|
||||
if (!writer.open()) {
|
||||
LOGGER.error("Failed to open configuration file");
|
||||
LOG_E(TAG, "Failed to open configuration file");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
#include <Tactility/service/gps/GpsService.h>
|
||||
|
||||
#include <Tactility/file/File.h>
|
||||
#include <Tactility/Logger.h>
|
||||
#include <Tactility/service/ServicePaths.h>
|
||||
#include <Tactility/service/ServiceManifest.h>
|
||||
#include <Tactility/service/ServiceRegistration.h>
|
||||
|
||||
#include <tactility/log.h>
|
||||
|
||||
using tt::hal::gps::GpsDevice;
|
||||
|
||||
namespace tt::service::gps {
|
||||
|
||||
static const auto LOGGER = Logger("GpsService");
|
||||
constexpr auto* TAG = "GpsService";
|
||||
extern const ServiceManifest manifest;
|
||||
|
||||
constexpr bool hasTimeElapsed(TickType_t now, TickType_t timeInThePast, TickType_t expireTimeInTicks) {
|
||||
@@ -73,7 +74,7 @@ void GpsService::onStop(ServiceContext& serviceContext) {
|
||||
}
|
||||
|
||||
bool GpsService::startGpsDevice(GpsDeviceRecord& record) {
|
||||
LOGGER.info("[device {}] starting", record.device->getId());
|
||||
LOG_I(TAG, "[device %u] starting", (unsigned)record.device->getId());
|
||||
|
||||
auto lock = mutex.asScopedLock();
|
||||
lock.lock();
|
||||
@@ -81,7 +82,7 @@ bool GpsService::startGpsDevice(GpsDeviceRecord& record) {
|
||||
auto device = record.device;
|
||||
|
||||
if (!device->start()) {
|
||||
LOGGER.error("[device {}] starting failed", record.device->getId());
|
||||
LOG_E(TAG, "[device %u] starting failed", (unsigned)record.device->getId());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -109,7 +110,7 @@ bool GpsService::startGpsDevice(GpsDeviceRecord& record) {
|
||||
}
|
||||
|
||||
bool GpsService::stopGpsDevice(GpsDeviceRecord& record) {
|
||||
LOGGER.info("[device {}] stopping", record.device->getId());
|
||||
LOG_I(TAG, "[device %u] stopping", (unsigned)record.device->getId());
|
||||
|
||||
auto device = record.device;
|
||||
|
||||
@@ -120,7 +121,7 @@ bool GpsService::stopGpsDevice(GpsDeviceRecord& record) {
|
||||
record.rmcSubscriptionId = -1;
|
||||
|
||||
if (!device->stop()) {
|
||||
LOGGER.error("[device {}] stopping failed", record.device->getId());
|
||||
LOG_E(TAG, "[device %u] stopping failed", (unsigned)record.device->getId());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -128,10 +129,10 @@ bool GpsService::stopGpsDevice(GpsDeviceRecord& record) {
|
||||
}
|
||||
|
||||
bool GpsService::startReceiving() {
|
||||
LOGGER.info("Start receiving");
|
||||
LOG_I(TAG, "Start receiving");
|
||||
|
||||
if (getState() != State::Off) {
|
||||
LOGGER.error("Already receiving");
|
||||
LOG_E(TAG, "Already receiving");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -144,13 +145,13 @@ bool GpsService::startReceiving() {
|
||||
|
||||
std::vector<hal::gps::GpsConfiguration> configurations;
|
||||
if (!getGpsConfigurations(configurations)) {
|
||||
LOGGER.error("Failed to get GPS configurations");
|
||||
LOG_E(TAG, "Failed to get GPS configurations");
|
||||
setState(State::Off);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (configurations.empty()) {
|
||||
LOGGER.error("No GPS configurations");
|
||||
LOG_E(TAG, "No GPS configurations");
|
||||
setState(State::Off);
|
||||
return false;
|
||||
}
|
||||
@@ -180,7 +181,7 @@ bool GpsService::startReceiving() {
|
||||
}
|
||||
|
||||
void GpsService::stopReceiving() {
|
||||
LOGGER.info("Stop receiving");
|
||||
LOG_I(TAG, "Stop receiving");
|
||||
|
||||
setState(State::OffPending);
|
||||
|
||||
@@ -198,11 +199,11 @@ void GpsService::stopReceiving() {
|
||||
}
|
||||
|
||||
void GpsService::onGgaSentence(hal::Device::Id deviceId, const minmea_sentence_gga& gga) {
|
||||
LOGGER.debug("[device {}] LAT {} LON {}, satellites: {}", deviceId, minmea_tocoord(&gga.latitude), minmea_tocoord(&gga.longitude), gga.satellites_tracked);
|
||||
LOG_D(TAG, "[device %u] LAT %f LON %f, satellites: %d", (unsigned)deviceId, minmea_tocoord(&gga.latitude), minmea_tocoord(&gga.longitude), gga.satellites_tracked);
|
||||
}
|
||||
|
||||
void GpsService::onRmcSentence(hal::Device::Id deviceId, const minmea_sentence_rmc& rmc) {
|
||||
LOGGER.debug("[device {}] LAT {} LON {}, speed: {}", deviceId, minmea_tocoord(&rmc.latitude), minmea_tocoord(&rmc.longitude), minmea_tofloat(&rmc.speed));
|
||||
LOG_D(TAG, "[device %u] LAT %f LON %f, speed: %f", (unsigned)deviceId, minmea_tocoord(&rmc.latitude), minmea_tocoord(&rmc.longitude), minmea_tofloat(&rmc.speed));
|
||||
}
|
||||
|
||||
State GpsService::getState() const {
|
||||
|
||||
Reference in New Issue
Block a user