lib: add TAI_ prefix to MACROs

Signed-off-by: Wataru Ishida <ishida@nel-america.com>
This commit is contained in:
Wataru Ishida
2020-01-14 22:25:31 +00:00
committed by Wataru Ishida
parent d07a6ffb97
commit eaafeb7ce5
6 changed files with 17 additions and 19 deletions

View File

@@ -255,7 +255,7 @@ namespace tai::framework {
}
if ( diff.size() == 0 ) {
DEBUG("already configured with the same configuration");
TAI_DEBUG("already configured with the same configuration");
return TAI_STATUS_SUCCESS;
}
@@ -309,7 +309,7 @@ namespace tai::framework {
return convert_tai_error_to_list(TAI_STATUS_ATTR_NOT_SUPPORTED_0, i);
}
if ( !force && !info->second.meta->isclearable ) {
WARN("can't clear non-clearable attribute: 0x%x", id);
TAI_WARN("can't clear non-clearable attribute: 0x%x", id);
return convert_tai_error_to_list(TAI_STATUS_INVALID_ATTR_VALUE_0, i);
}
m_config.erase(id);
@@ -358,12 +358,12 @@ namespace tai::framework {
tai_status_t _set(S_Attribute src, bool readonly, bool without_hook, FSMState* fsm = nullptr) {
auto info = m_info.find(src->id());
if ( info == m_info.end() ) {
DEBUG("no meta: 0x%x", src->id());
TAI_DEBUG("no meta: 0x%x", src->id());
return TAI_STATUS_ATTR_NOT_SUPPORTED_0;
}
if ( !readonly && info->second.meta->isreadonly) {
WARN("read only: 0x%x", src->id());
TAI_WARN("read only: 0x%x", src->id());
return TAI_STATUS_INVALID_ATTR_VALUE_0;
}
@@ -386,7 +386,7 @@ namespace tai::framework {
tai_status_t _set(const tai_attribute_t& src, bool readonly, bool without_hook, FSMState* fsm = nullptr) {
auto info = m_info.find(src.id);
if ( info == m_info.end() ) {
DEBUG("no meta: 0x%x", src.id);
TAI_DEBUG("no meta: 0x%x", src.id);
return TAI_STATUS_ATTR_NOT_SUPPORTED_0;
}
auto attr = std::make_shared<Attribute>(info->second.meta, src);

View File

@@ -238,7 +238,7 @@ namespace tai::basic {
return TAI_STATUS_ITEM_NOT_FOUND;
}
if ( m_netif != nullptr || m_hostif[0] != nullptr || m_hostif[1] != nullptr ) {
WARN("can't remove a module before removing its siblings");
TAI_WARN("can't remove a module before removing its siblings");
return TAI_STATUS_OBJECT_IN_USE;
}
transite(FSM_STATE_END);
@@ -290,12 +290,12 @@ namespace tai::basic {
// in this example, it doesn't do anything.
// by default, the attribute gets stored to config structure
// after calling this callback.
INFO("setting tx-dis to %s", attribute->value.booldata ? "true" : "false");
TAI_INFO("setting tx-dis to %s", attribute->value.booldata ? "true" : "false");
return TAI_STATUS_SUCCESS;
}
tai_status_t FSM::get_tx_dis(tai_attribute_t* const attribute) {
INFO("getting tx-dis");
TAI_INFO("getting tx-dis");
// you will access hardware here to get tx-dis
// in this example, we get the attribute from the netif config.
auto& config = m_netif->config();
@@ -348,7 +348,7 @@ namespace tai::basic {
TAI_MODULE_ATTR_OPER_STATUS,
});
}
INFO("%s -> %s", to_string(current).c_str(), to_string(next).c_str());
TAI_INFO("%s -> %s", to_string(current).c_str(), to_string(next).c_str());
return next;
}

View File

@@ -146,7 +146,7 @@ namespace tai::framework {
try {
attr = std::make_shared<Attribute>(meta, f);
} catch (Exception &e) {
ERROR("getting attribute %s for notification failed: %s", meta->attridshortname, e.what());
TAI_ERROR("getting attribute %s for notification failed: %s", meta->attridshortname, e.what());
continue;
}
ptrs.emplace_back(attr); // only used for memory management

View File

@@ -1,7 +1,6 @@
#include <iostream>
#include <memory>
#include "tai.h"
#include "logger.hpp"
#include "exception.hpp"
static std::unique_ptr<tai::framework::Platform> g_platform;

View File

@@ -69,14 +69,14 @@ namespace tai {
std::mutex m_mtx;
};
#define _LOG(api, level, format, ...) ::tai::Logger::get_instance().log(api, level, __FILE__, __LINE__, __PRETTY_FUNCTION__, format, ##__VA_ARGS__)
#define LOG(level, format, ...) _LOG(TAI_API_UNSPECIFIED, level, format, ##__VA_ARGS__)
#define _TAI_LOG(api, level, format, ...) ::tai::Logger::get_instance().log(api, level, __FILE__, __LINE__, __PRETTY_FUNCTION__, format, ##__VA_ARGS__)
#define TAI_LOG(level, format, ...) _TAI_LOG(TAI_API_UNSPECIFIED, level, format, ##__VA_ARGS__)
#define DEBUG(format, ...) LOG(TAI_LOG_LEVEL_DEBUG, format, ##__VA_ARGS__)
#define INFO(format, ...) LOG(TAI_LOG_LEVEL_INFO, format, ##__VA_ARGS__)
#define WARN(format, ...) LOG(TAI_LOG_LEVEL_WARN, format, ##__VA_ARGS__)
#define ERROR(format, ...) LOG(TAI_LOG_LEVEL_ERROR, format, ##__VA_ARGS__)
#define CRITICAL(format, ...) LOG(TAI_LOG_LEVEL_CRITICAL, format, ##__VA_ARGS__)
#define TAI_DEBUG(format, ...) TAI_LOG(TAI_LOG_LEVEL_DEBUG, format, ##__VA_ARGS__)
#define TAI_INFO(format, ...) TAI_LOG(TAI_LOG_LEVEL_INFO, format, ##__VA_ARGS__)
#define TAI_WARN(format, ...) TAI_LOG(TAI_LOG_LEVEL_WARN, format, ##__VA_ARGS__)
#define TAI_ERROR(format, ...) TAI_LOG(TAI_LOG_LEVEL_ERROR, format, ##__VA_ARGS__)
#define TAI_CRITICAL(format, ...) TAI_LOG(TAI_LOG_LEVEL_CRITICAL, format, ##__VA_ARGS__)
}

View File

@@ -17,7 +17,6 @@
#include <chrono>
#include <functional>
#include "attribute.hpp"
#include "logger.hpp"
using grpc::Status;
using grpc::StatusCode;