You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by si...@apache.org on 2019/01/03 23:28:06 UTC

[pulsar] branch master updated: Pulsar CPP CLient - making log messages more meaningful. (#3285)

This is an automated email from the ASF dual-hosted git repository.

sijie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar.git


The following commit(s) were added to refs/heads/master by this push:
     new c0c2dda  Pulsar CPP CLient - making log messages more meaningful. (#3285)
c0c2dda is described below

commit c0c2dda9379f2617e1329bfb6e75a0cd41a54523
Author: Jai Asher <ja...@ccs.neu.edu>
AuthorDate: Thu Jan 3 15:28:01 2019 -0800

    Pulsar CPP CLient - making log messages more meaningful. (#3285)
    
    ### Motivation
    While debugging we realized that there were log messages in the cpp client which were not of much use since topic names weren't mentioned and closing a Client/Consumer/Producer message was under DEBUG instead of INFO.
    
    ### Modifications
    Added topic names to the relevant messages and changed log level to info for closing a Client/Consumer/Producer message.
    
    ### Result
    Logs make a little more sense.
---
 pulsar-client-cpp/lib/Client.cc       | 2 +-
 pulsar-client-cpp/lib/ClientImpl.cc   | 8 +++++---
 pulsar-client-cpp/lib/ConsumerImpl.cc | 3 ++-
 pulsar-client-cpp/lib/ProducerImpl.cc | 2 +-
 4 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/pulsar-client-cpp/lib/Client.cc b/pulsar-client-cpp/lib/Client.cc
index 2353b4b..693282e 100644
--- a/pulsar-client-cpp/lib/Client.cc
+++ b/pulsar-client-cpp/lib/Client.cc
@@ -86,7 +86,7 @@ void Client::subscribeAsync(const std::string& topic, const std::string& consume
 
 void Client::subscribeAsync(const std::string& topic, const std::string& consumerName,
                             const ConsumerConfiguration& conf, SubscribeCallback callback) {
-    LOG_DEBUG("Topic is :" << topic);
+    LOG_INFO("Subscribing on Topic :" << topic);
     impl_->subscribeAsync(topic, consumerName, conf, callback);
 }
 
diff --git a/pulsar-client-cpp/lib/ClientImpl.cc b/pulsar-client-cpp/lib/ClientImpl.cc
index 5478dd7..747a504 100644
--- a/pulsar-client-cpp/lib/ClientImpl.cc
+++ b/pulsar-client-cpp/lib/ClientImpl.cc
@@ -213,7 +213,8 @@ void ClientImpl::handleReaderMetadataLookup(const Result result, const LookupDat
                                             TopicNamePtr topicName, MessageId startMessageId,
                                             ReaderConfiguration conf, ReaderCallback callback) {
     if (result != ResultOk) {
-        LOG_ERROR("Error Checking/Getting Partition Metadata while creating reader: " << result);
+        LOG_ERROR("Error Checking/Getting Partition Metadata while creating readeron "
+                  << topicName->toString() << " -- " << result);
         callback(result, Reader());
         return;
     }
@@ -373,7 +374,8 @@ void ClientImpl::handleSubscribe(const Result result, const LookupDataResultPtr
         lock.unlock();
         consumer->start();
     } else {
-        LOG_ERROR("Error Checking/Getting Partition Metadata while Subscribing- " << result);
+        LOG_ERROR("Error Checking/Getting Partition Metadata while Subscribing on " << topicName->toString()
+                                                                                    << " -- " << result);
         callback(result, Consumer());
     }
 }
@@ -468,7 +470,7 @@ void ClientImpl::closeAsync(CloseCallback callback) {
     state_ = Closing;
     lock.unlock();
 
-    LOG_DEBUG("Closing Pulsar client");
+    LOG_INFO("Closing Pulsar client");
     SharedInt numberOfOpenHandlers = boost::make_shared<int>(producers.size() + consumers.size());
 
     for (ProducersList::iterator it = producers.begin(); it != producers.end(); ++it) {
diff --git a/pulsar-client-cpp/lib/ConsumerImpl.cc b/pulsar-client-cpp/lib/ConsumerImpl.cc
index 06eb43f..2f19ba6 100644
--- a/pulsar-client-cpp/lib/ConsumerImpl.cc
+++ b/pulsar-client-cpp/lib/ConsumerImpl.cc
@@ -700,7 +700,7 @@ void ConsumerImpl::doAcknowledge(const MessageId& messageId, proto::CommandAck_A
 }
 
 void ConsumerImpl::disconnectConsumer() {
-    LOG_DEBUG("Broker notification of Closed consumer: " << consumerId_);
+    LOG_INFO("Broker notification of Closed consumer: " << consumerId_);
     Lock lock(mutex_);
     connection_.reset();
     lock.unlock();
@@ -727,6 +727,7 @@ void ConsumerImpl::closeAsync(ResultCallback callback) {
         return;
     }
 
+    LOG_INFO(getName() << "Closing consumer for topic " << topic_);
     ClientImplPtr client = client_.lock();
     if (!client) {
         lock.unlock();
diff --git a/pulsar-client-cpp/lib/ProducerImpl.cc b/pulsar-client-cpp/lib/ProducerImpl.cc
index 32f178c..29d081b 100644
--- a/pulsar-client-cpp/lib/ProducerImpl.cc
+++ b/pulsar-client-cpp/lib/ProducerImpl.cc
@@ -467,7 +467,7 @@ void ProducerImpl::closeAsync(CloseCallback callback) {
         }
         return;
     }
-    LOG_DEBUG(getName() << "Closing producer");
+    LOG_INFO(getName() << "Closing producer for topic " << topic_);
     state_ = Closing;
 
     ClientConnectionPtr cnx = getCnx().lock();