Using log fuction in Logging instead of spd directly
diff --git a/src/main/cpp/sdk/ConsumerImpl.cpp b/src/main/cpp/sdk/ConsumerImpl.cpp
index 286e96d..7164b02 100644
--- a/src/main/cpp/sdk/ConsumerImpl.cpp
+++ b/src/main/cpp/sdk/ConsumerImpl.cpp
@@ -36,7 +36,7 @@
graal_isolatethread_t *thread_;
ThreadAttachment attachment(&thread_);
this->instanceIndex_ = create_consumer(thread_, &property);
- spdlog::info("Create Consumer OK, InstanceId:{}, ConsumerID:{}, NameServer:{}, Trace:{}, MessageModel:{}",
+ rocketmq::spd_log::info("Create Consumer OK, InstanceId:{}, ConsumerID:{}, NameServer:{}, Trace:{}, MessageModel:{}",
instanceIndex_, factoryProperty.getConsumerId(),
factoryProperty.getNameSrvAddr(), factoryProperty.getOnsTraceSwitch(),
factoryProperty.getMessageModel());
@@ -46,7 +46,7 @@
graal_isolatethread_t *thread_;
ThreadAttachment attachment(&thread_);
start_instance(thread_, instanceIndex_);
- spdlog::info("Start Consumer instance {} OK", instanceIndex_);
+ rocketmq::spd_log::info("Start Consumer instance {} OK", instanceIndex_);
}
#ifdef __cplusplus
@@ -67,7 +67,7 @@
case CommitMessage:
return 0;
case ReconsumeLater:
- spdlog::info("Consume Message failed, Topic:{}, MessageId:{}, RecosumeTimes:{}",
+ rocketmq::spd_log::info("Consume Message failed, Topic:{}, MessageId:{}, RecosumeTimes:{}",
message_.getTopic(), message_.getMsgID(), message_.getReconsumeTimes());
return 1;
default:
@@ -100,14 +100,14 @@
graal_isolatethread_t *thread_;
ThreadAttachment attachment(&thread_);
::subscribe(thread_, instanceIndex_, &sub);
- spdlog::info("Subscribe OK, InstanceID:{}, Topic:{}, SubExpression:{}", instanceIndex_, topic, subExpression);
+ rocketmq::spd_log::info("Subscribe OK, InstanceID:{}, Topic:{}, SubExpression:{}", instanceIndex_, topic, subExpression);
}
void ConsumerImpl::shutdown() {
graal_isolatethread_t *thread_;
ThreadAttachment attachment(&thread_);
destroy_instance(thread_, instanceIndex_);
- spdlog::info("Destroy Consumer instance {} OK", instanceIndex_);
+ rocketmq::spd_log::info("Destroy Consumer instance {} OK", instanceIndex_);
}
ConsumerImpl::~ConsumerImpl() {
diff --git a/src/main/cpp/sdk/OrderConsumerImpl.cpp b/src/main/cpp/sdk/OrderConsumerImpl.cpp
index 496f263..0b36224 100644
--- a/src/main/cpp/sdk/OrderConsumerImpl.cpp
+++ b/src/main/cpp/sdk/OrderConsumerImpl.cpp
@@ -31,7 +31,7 @@
factory_property property;
ons::FactoryPropertyConverter converter(factoryProperty, property, false);
this->instanceIndex_ = create_order_consumer(thread_, &property);
- spdlog::info("Create Order Consumer OK, InstanceId:{}, ConsumerID:{}, NameServer:{}",
+ rocketmq::spd_log::info("Create Order Consumer OK, InstanceId:{}, ConsumerID:{}, NameServer:{}",
instanceIndex_, factoryProperty.getConsumerId(), factoryProperty.getNameSrvAddr());
}
@@ -43,14 +43,14 @@
graal_isolatethread_t *thread_;
ThreadAttachment attachment(&thread_);
start_instance(thread_, instanceIndex_);
- spdlog::info("Start Order Consumer instance {} OK", instanceIndex_);
+ rocketmq::spd_log::info("Start Order Consumer instance {} OK", instanceIndex_);
}
void OrderConsumerImpl::shutdown() {
graal_isolatethread_t *thread_;
ThreadAttachment attachment(&thread_);
destroy_instance(thread_, instanceIndex_);
- spdlog::info("Destroy Order Consumer instance {} OK", instanceIndex_);
+ rocketmq::spd_log::info("Destroy Order Consumer instance {} OK", instanceIndex_);
}
#ifdef __cplusplus
@@ -70,7 +70,7 @@
case Success:
return 0;
case Suspend:
- spdlog::info("Consume Order Message failed, Topic:{}, MessageId:{}, RecosumeTimes:{}",
+ rocketmq::spd_log::info("Consume Order Message failed, Topic:{}, MessageId:{}, RecosumeTimes:{}",
message_.getTopic(), message_.getMsgID(), message_.getReconsumeTimes());
return 1;
default:
@@ -104,5 +104,5 @@
graal_isolatethread_t *thread_;
ThreadAttachment attachment(&thread_);
::subscribe_order_listener(thread_, instanceIndex_, &sub);
- spdlog::info("Subscribe OK, InstanceID:{}, Topic:{}, SubExpression:{}", instanceIndex_, topic, subExpression);
+ rocketmq::spd_log::info("Subscribe OK, InstanceID:{}, Topic:{}, SubExpression:{}", instanceIndex_, topic, subExpression);
}
\ No newline at end of file
diff --git a/src/main/cpp/sdk/OrderProducerImpl.cpp b/src/main/cpp/sdk/OrderProducerImpl.cpp
index 2e78f6f..d0d6414 100644
--- a/src/main/cpp/sdk/OrderProducerImpl.cpp
+++ b/src/main/cpp/sdk/OrderProducerImpl.cpp
@@ -33,7 +33,7 @@
factory_property fp;
FactoryPropertyConverter converter(factoryProperty, fp);
instanceIndex_ = create_order_producer(thread_, &fp);
- spdlog::info("Create Order Producer OK, InstanceId:{}, ProducerID:{}, NameServer:{}",
+ rocketmq::spd_log::info("Create Order Producer OK, InstanceId:{}, ProducerID:{}, NameServer:{}",
instanceIndex_, factoryProperty.getProducerId(), factoryProperty.getNameSrvAddr());
}
@@ -49,7 +49,7 @@
graal_isolatethread_t *thread_;
ThreadAttachment attachment(&thread_);
destroy_instance(thread_, instanceIndex_);
- spdlog::info("Destroy Order Producer instance {} OK", instanceIndex_);
+ rocketmq::spd_log::info("Destroy Order Producer instance {} OK", instanceIndex_);
}
SendResultONS OrderProducerImpl::send(Message &msg, std::string shardingKey) throw(ons::ONSClientException) {
@@ -64,7 +64,7 @@
ONSClientException clientException(std::string(sendResult.error_msg), sendResult.error_no);
throw clientException;
}
- spdlog::debug("Send message OK. MsgId: {}", sendResult.message_id);
+ rocketmq::spd_log::debug("Send message OK. MsgId: {}", sendResult.message_id);
SendResultONS sendResultOns;
sendResultOns.setMessageId(std::string(sendResult.message_id));
return sendResultOns;
diff --git a/src/main/cpp/sdk/ProducerImpl.cpp b/src/main/cpp/sdk/ProducerImpl.cpp
index cd4085a..29c3868 100644
--- a/src/main/cpp/sdk/ProducerImpl.cpp
+++ b/src/main/cpp/sdk/ProducerImpl.cpp
@@ -35,7 +35,7 @@
factory_property fp;
FactoryPropertyConverter converter(factoryProperty, fp);
instanceIndex_ = create_producer(thread_, &fp);
- spdlog::info("Create Producer OK, InstanceId:{}, ProducerID:{}, NameServer:{}",
+ rocketmq::spd_log::info("Create Producer OK, InstanceId:{}, ProducerID:{}, NameServer:{}",
instanceIndex_, factoryProperty.getProducerId(), factoryProperty.getNameSrvAddr());
}
@@ -51,7 +51,7 @@
graal_isolatethread_t *thread_;
ThreadAttachment attachment(&thread_);
destroy_instance(thread_, instanceIndex_);
- spdlog::info("Destroy Producer instance {} OK", instanceIndex_);
+ rocketmq::spd_log::info("Destroy Producer instance {} OK", instanceIndex_);
}
ons::SendResultONS ProducerImpl::send(Message &msg) throw(ONSClientException) {
@@ -65,7 +65,7 @@
if (sendResult.error_no) {
throw ONSClientException(std::string(sendResult.error_msg), sendResult.error_no);
}
- spdlog::debug("Send message OK. MsgId: {}", sendResult.message_id);
+ rocketmq::spd_log::debug("Send message OK. MsgId: {}", sendResult.message_id);
SendResultONS sendResultOns;
sendResultOns.setMessageId(std::string(sendResult.message_id));
return sendResultOns;
diff --git a/src/main/cpp/sdk/TransactionProducerImpl.cpp b/src/main/cpp/sdk/TransactionProducerImpl.cpp
index 31f8db8..c0c5178 100644
--- a/src/main/cpp/sdk/TransactionProducerImpl.cpp
+++ b/src/main/cpp/sdk/TransactionProducerImpl.cpp
@@ -61,7 +61,7 @@
void *checker = reinterpret_cast<void *>(pTransactionCheckListener);
void *transaction_check = (void *) transaction_check_func;
instanceIndex_ = create_transaction_producer(thread_, &fp, checker, transaction_check);
- spdlog::info("Create Transaction Producer OK, InstanceId:{}, ProducerID:{}, NameServer:{}",
+ rocketmq::spd_log::info("Create Transaction Producer OK, InstanceId:{}, ProducerID:{}, NameServer:{}",
instanceIndex_, factoryProperty.getProducerId(), factoryProperty.getNameSrvAddr());
}
@@ -76,7 +76,7 @@
graal_isolatethread_t *thread_;
ThreadAttachment attachment(&thread_);
destroy_instance(thread_, instanceIndex_);
- spdlog::info("Destroy Transaction Producer instance {} OK", instanceIndex_);
+ rocketmq::spd_log::info("Destroy Transaction Producer instance {} OK", instanceIndex_);
}
SendResultONS TransactionProducerImpl::send(Message &msg, LocalTransactionExecuter *pTransactionExecutor) {
diff --git a/src/main/cpp/sdk/common/Logger.h b/src/main/cpp/sdk/common/Logger.h
index 2d90237..f547c9b 100644
--- a/src/main/cpp/sdk/common/Logger.h
+++ b/src/main/cpp/sdk/common/Logger.h
@@ -61,6 +61,66 @@
static void flushLogger();
+ template<typename... Args>
+ static inline void trace(const char *fmt, const Args &... args) {
+ spdlog::trace(fmt, args...);
+ }
+
+ template<typename... Args>
+ static inline void debug(const char *fmt, const Args &... args) {
+ spdlog::debug(fmt, args...);
+ }
+
+ template<typename... Args>
+ static inline void info(const char *fmt, const Args &... args) {
+ spdlog::info(fmt, args...);
+ }
+
+ template<typename... Args>
+ static inline void warn(const char *fmt, const Args &... args) {
+ spdlog::warn(fmt, args...);
+ }
+
+ template<typename... Args>
+ static inline void error(const char *fmt, const Args &... args) {
+ spdlog::error(fmt, args...);
+ }
+
+ template<typename... Args>
+ static inline void critical(const char *fmt, const Args &... args) {
+ spdlog::critical(fmt, args...);
+ }
+
+ template<typename T>
+ static inline void trace(const T &msg) {
+ spdlog::trace(msg);
+ }
+
+ template<typename T>
+ static inline void debug(const T &msg) {
+ spdlog::debug(msg);
+ }
+
+ template<typename T>
+ static inline void info(const T &msg) {
+ spdlog::info(msg);
+ }
+
+ template<typename T>
+ static inline void warn(const T &msg) {
+ spdlog::warn(msg);
+ }
+
+ template<typename T>
+ static inline void error(const T &msg) {
+ spdlog::error(msg);
+ }
+
+ template<typename T>
+ static inline void critical(const T &msg) {
+ spdlog::critical(msg);
+ }
+
private:
static int isDir(std::string path);
diff --git a/src/main/cpp/sdk/common/UtilAll.h b/src/main/cpp/sdk/common/UtilAll.h
index 45baebe..dae436b 100644
--- a/src/main/cpp/sdk/common/UtilAll.h
+++ b/src/main/cpp/sdk/common/UtilAll.h
@@ -60,7 +60,7 @@
static graal_isolate_t *singleton = nullptr;
if (nullptr == singleton) {
if (graal_create_isolate(nullptr, &singleton, nullptr)) {
- spdlog::error("Failed to create graal isolate");
+ rocketmq::spd_log::error("Failed to create graal isolate");
return nullptr;
}
}
@@ -168,7 +168,7 @@
++isolate_thread_ref_cnt;
if (graal_attach_thread(UtilAll::get_isolate(), thread)) {
- spdlog::error("Failed to attach native thread {} to graal isolate", ss.str());
+ rocketmq::spd_log::error("Failed to attach native thread {} to graal isolate", ss.str());
throw ons::ONSClientException("attach thread to isolate failed", -1);
}
@@ -176,7 +176,7 @@
pthread_key_create(&key, &ThreadAttachment::detach);
pthread_setspecific(key, &ThreadAttachment::isolate_thread_ref_cnt);
- spdlog::debug("Attach thread {} to isolate OK", ss.str());
+ rocketmq::spd_log::debug("Attach thread {} to isolate OK", ss.str());
}
~ThreadAttachment() {
@@ -188,7 +188,7 @@
graal_detach_thread(attached);
std::stringstream ss;
ss << std::this_thread::get_id();
- spdlog::debug("Detach thread {} from isolate OK", ss.str());
+ rocketmq::spd_log::debug("Detach thread {} from isolate OK", ss.str());
}
}
diff --git a/src/test/cpp/LoggerTest.cpp b/src/test/cpp/LoggerTest.cpp
index 8e9d1cb..bd9c963 100644
--- a/src/test/cpp/LoggerTest.cpp
+++ b/src/test/cpp/LoggerTest.cpp
@@ -5,5 +5,5 @@
TEST(LoggerTest, testLog) {
rocketmq::spd_log::initLogger();
- spdlog::debug("This is a debug line");
+ rocketmq::spd_log::debug("This is a debug line");
}
\ No newline at end of file