From 17a382f0da1c594b5a02f8b40c676258c8dbeb05 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Mon, 11 Aug 2014 14:23:01 +0000 Subject: NO-JIRA: Clean up excessive "notice" level log messages, add start-up/shut-down messages. - Demote excessive "notice" level log messages to "info" - Provide clear notice "start-up/shut-down" messages at start and end of broker log. - Log broker PID in start-up/shut-down messages. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1617293 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/qpid/broker/Broker.cpp | 21 +++++++++++++-------- qpid/cpp/src/qpid/broker/Broker.h | 10 +++++++++- qpid/cpp/src/qpid/broker/Daemon.cpp | 5 ++--- qpid/cpp/src/qpid/linearstore/JournalImpl.cpp | 6 +++--- qpid/cpp/src/qpid/linearstore/MessageStoreImpl.cpp | 4 ++-- .../linearstore/journal/EmptyFilePoolManager.cpp | 2 +- 6 files changed, 30 insertions(+), 18 deletions(-) (limited to 'qpid/cpp/src') diff --git a/qpid/cpp/src/qpid/broker/Broker.cpp b/qpid/cpp/src/qpid/broker/Broker.cpp index 6648ae706d..f244c9852c 100644 --- a/qpid/cpp/src/qpid/broker/Broker.cpp +++ b/qpid/cpp/src/qpid/broker/Broker.cpp @@ -209,6 +209,13 @@ framing::FieldTable noReplicateArgs() { } } +Broker::LogPrefix::LogPrefix() : + std::string(Msg() << "Broker (pid=" << sys::SystemInfo::getProcessId() << ") ") { + QPID_LOG(notice, *this << "start-up"); +} + +Broker::LogPrefix::~LogPrefix() { QPID_LOG(notice, *this << "shut-down"); } + Broker::Broker(const BrokerOptions& conf) : poller(new Poller), timer(new qpid::sys::Timer), @@ -236,10 +243,8 @@ Broker::Broker(const BrokerOptions& conf) : queueCleaner(queues, poller, timer.get()), recoveryInProgress(false), timestampRcvMsgs(conf.timestampRcvMsgs), - logPrefix(Msg() << "Broker " << sys::SystemInfo::getProcessId()), getKnownBrokers(boost::bind(&Broker::getKnownBrokersImpl, this)) { - QPID_LOG(notice, logPrefix << " initializing"); if (!dataDir.isEnabled()) { QPID_LOG (info, "No data directory - Disabling persistent configuration"); } @@ -386,11 +391,12 @@ Broker::Broker(const BrokerOptions& conf) : knownBrokers.push_back(Url(conf.knownHosts)); } - } catch (const std::exception&) { + } catch (const std::exception& e) { + QPID_LOG(critical, logPrefix << "start-up failed: " << e.what()); finalize(); throw; } - QPID_LOG(notice, logPrefix << " initialized"); + QPID_LOG(info, logPrefix << "initialized"); } void Broker::declareStandardExchange(const std::string& name, const std::string& type) @@ -502,7 +508,7 @@ void Broker::setStore () { void Broker::run() { if (config.workerThreads > 0) { - QPID_LOG(notice, logPrefix << " running"); + QPID_LOG(info, logPrefix << "running"); Dispatcher d(poller); int numIOThreads = config.workerThreads; std::vector t(numIOThreads-1); @@ -518,7 +524,7 @@ void Broker::run() { for (int i=0; idebugStats("destroying"); shutdown(); @@ -541,7 +547,6 @@ Broker::~Broker() { SaslAuthenticator::fini(); timer->stop(); managementAgent.reset(); - QPID_LOG(notice, logPrefix << " shutdown complete"); } ManagementObject::shared_ptr Broker::GetManagementObject(void) const diff --git a/qpid/cpp/src/qpid/broker/Broker.h b/qpid/cpp/src/qpid/broker/Broker.h index 46dbe5d5b5..3dbe407cff 100644 --- a/qpid/cpp/src/qpid/broker/Broker.h +++ b/qpid/cpp/src/qpid/broker/Broker.h @@ -123,6 +123,15 @@ class Broker : public sys::Runnable, public Plugin::Target, const Connection* context); Manageable::status_t queueRedirect(const std::string& srcQueue, const std::string& tgtQueue, const Connection* context); void queueRedirectDestroy(boost::shared_ptr srcQ, boost::shared_ptr tgtQ, bool moveMsgs); + + // This must be the first member of Broker. It logs a start-up message + // at the start of Broker construction and a shut-down message at the + // end of destruction. + struct LogPrefix : public std::string { + LogPrefix(); + ~LogPrefix(); + } logPrefix; + boost::shared_ptr poller; std::auto_ptr timer; const BrokerOptions& config; @@ -160,7 +169,6 @@ class Broker : public sys::Runnable, public Plugin::Target, mutable sys::Mutex linkClientPropertiesLock; framing::FieldTable linkClientProperties; bool timestampRcvMsgs; - std::string logPrefix; public: QPID_BROKER_EXTERN virtual ~Broker(); diff --git a/qpid/cpp/src/qpid/broker/Daemon.cpp b/qpid/cpp/src/qpid/broker/Daemon.cpp index 5b6f898332..9f7a5b3f2d 100644 --- a/qpid/cpp/src/qpid/broker/Daemon.cpp +++ b/qpid/cpp/src/qpid/broker/Daemon.cpp @@ -91,8 +91,7 @@ void Daemon::fork() child(); } catch (const exception& e) { - QPID_LOG(critical, "Unexpected error: " << e.what()); - uint16_t port = 0; + uint16_t port = 0; if (write(pipeFds[1], &port, sizeof(uint16_t))) {}; std::string pipeFailureMessage = e.what(); @@ -115,7 +114,7 @@ Daemon::~Daemon() { uint16_t Daemon::wait(int timeout) { // parent waits for child. try { - errno = 0; + errno = 0; struct timeval tv; tv.tv_sec = timeout; tv.tv_usec = 0; diff --git a/qpid/cpp/src/qpid/linearstore/JournalImpl.cpp b/qpid/cpp/src/qpid/linearstore/JournalImpl.cpp index 18cf0619e4..113533776c 100644 --- a/qpid/cpp/src/qpid/linearstore/JournalImpl.cpp +++ b/qpid/cpp/src/qpid/linearstore/JournalImpl.cpp @@ -78,7 +78,7 @@ JournalImpl::JournalImpl(::qpid::sys::Timer& timer_, initManagement(a); - QLS_LOG2(notice, _jid, "Created"); + QLS_LOG2(info, _jid, "Created"); std::ostringstream oss; oss << "Journal directory = \"" << journalDirectory << "\""; QLS_LOG2(debug, _jid, oss.str()); @@ -99,7 +99,7 @@ JournalImpl::~JournalImpl() _mgmtObject.reset(); } - QLS_LOG2(notice, _jid, "Destroyed"); + QLS_LOG2(info, _jid, "Destroyed"); } void @@ -136,7 +136,7 @@ JournalImpl::initialize(::qpid::linearstore::journal::EmptyFilePool* efpp_, ::qpid::linearstore::journal::aio_callback* const cbp) { // efpp->createJournal(_jdir); -// QLS_LOG2(notice, _jid, "Initialized"); +// QLS_LOG2(info, _jid, "Initialized"); // std::ostringstream oss; //// oss << "Initialize; num_jfiles=" << num_jfiles << " jfsize_sblks=" << jfsize_sblks; // oss << "Initialize; efpPartitionNumber=" << efpp_->getPartitionNumber(); diff --git a/qpid/cpp/src/qpid/linearstore/MessageStoreImpl.cpp b/qpid/cpp/src/qpid/linearstore/MessageStoreImpl.cpp index b7c6672c61..5431862d6a 100644 --- a/qpid/cpp/src/qpid/linearstore/MessageStoreImpl.cpp +++ b/qpid/cpp/src/qpid/linearstore/MessageStoreImpl.cpp @@ -201,7 +201,7 @@ bool MessageStoreImpl::init(const std::string& storeDir_, else init(); - QLS_LOG(notice, "Store module initialized; store-dir=" << storeDir_); + QLS_LOG(info, "Store module initialized; store-dir=" << storeDir_); QLS_LOG(info, "> Default EFP partition: " << defaultEfpPartitionNumber); QLS_LOG(info, "> Default EFP file size: " << defaultEfpFileSize_kib << " (KiB)"); QLS_LOG(info, "> Default write cache page size: " << wCachePageSizeKib_ << " (KiB)"); @@ -337,7 +337,7 @@ void MessageStoreImpl::truncateInit() qpid::linearstore::journal::jdir::delete_dir(getBdbBaseDir()); qpid::linearstore::journal::jdir::delete_dir(getJrnlBaseDir()); qpid::linearstore::journal::jdir::delete_dir(getTplBaseDir()); - QLS_LOG(notice, "Store directory " << getStoreTopLevelDir() << " was truncated."); + QLS_LOG(info, "Store directory " << getStoreTopLevelDir() << " was truncated."); init(); } diff --git a/qpid/cpp/src/qpid/linearstore/journal/EmptyFilePoolManager.cpp b/qpid/cpp/src/qpid/linearstore/journal/EmptyFilePoolManager.cpp index dc675f43a5..3109f3e73b 100644 --- a/qpid/cpp/src/qpid/linearstore/journal/EmptyFilePoolManager.cpp +++ b/qpid/cpp/src/qpid/linearstore/journal/EmptyFilePoolManager.cpp @@ -91,7 +91,7 @@ void EmptyFilePoolManager::findEfpPartitions() { } } - journalLogRef_.log(JournalLog::LOG_NOTICE, "EFP Manager initialization complete"); + journalLogRef_.log(JournalLog::LOG_INFO, "EFP Manager initialization complete"); std::vector partitionList; std::vector filePoolList; getEfpPartitions(partitionList); -- cgit v1.2.1