]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
log: remove "boost/asio.hpp" from Log.h
authorKefu Chai <kchai@redhat.com>
Fri, 5 Feb 2016 07:56:55 +0000 (15:56 +0800)
committerKefu Chai <kchai@redhat.com>
Wed, 10 Feb 2016 05:27:25 +0000 (21:27 -0800)
graylog uses boost/asio.hpp which introduces the link-time dependency on
libboost_system to the compilation units which includes Log.h and
LogClient.h. so it appears that perfglue/heap_profiler.cc is referencing
libboost_system.so, and fails the cmake build of all tests which links
against tcmalloc.

in this change, we:

* remove unnecessary #includes from Graylog.h
* forward declare Graylog class, so that "Graylog.h" is not included in
  any header files to avoid the link-time dependency pollution

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/common/Graylog.cc
src/common/Graylog.h
src/common/LogClient.cc
src/common/LogClient.h
src/common/ceph_context.cc
src/log/Log.cc
src/log/Log.h
src/mon/LogMonitor.cc
src/mon/LogMonitor.h

index 8dde3d0ad0f3f3d9ebd383fd4495009f27bd25fb..dd4f3b29c0e3a7f762df1943c630ad598923c3d4 100644 (file)
@@ -5,16 +5,15 @@
 
 #include <iostream>
 #include <sstream>
-#include <memory>
 
 #include <arpa/inet.h>
 
-#include <boost/asio.hpp>
-#include <boost/iostreams/filtering_stream.hpp>
-#include <boost/iostreams/filter/zlib.hpp>
 #include <boost/lexical_cast.hpp>
 
 #include "common/Formatter.h"
+#include "common/LogEntry.h"
+#include "log/Entry.h"
+#include "log/SubsystemMap.h"
 #include "include/uuid.h"
 
 namespace ceph {
@@ -71,7 +70,7 @@ void Graylog::set_hostname(const std::string& host)
   m_hostname = host;
 }
 
-void Graylog::set_fsid(uuid_d fsid)
+void Graylog::set_fsid(const uuid_d& fsid)
 {
   std::vector<char> buf(40);
   fsid.print(&buf[0]);
index 7caa6564af5279851ca841863e68d10974e46ec7..bac437f1d1cfd7c6cc426f962c235a26afbf8c00 100644 (file)
@@ -7,19 +7,24 @@
 
 #include <memory>
 
-#include <boost/thread/mutex.hpp>
 #include <boost/asio.hpp>
 #include <boost/iostreams/filtering_stream.hpp>
 #include <boost/iostreams/filter/zlib.hpp>
 
-#include "log/Entry.h"
-#include "log/SubsystemMap.h"
-#include "common/LogEntry.h"
 #include "include/memory.h"
 
+struct uuid_d;
+class LogEntry;
+
 namespace ceph {
+
+class Formatter;
+
 namespace log {
 
+struct Entry;
+class SubsystemMap;
+
 // Graylog logging backend: Convert log datastructures (LogEntry, Entry) to
 // GELF (http://www.graylog2.org/resources/gelf/specification) and send it
 // to a GELF UDP receiver
@@ -45,7 +50,7 @@ class Graylog
   virtual ~Graylog();
 
   void set_hostname(const std::string& host);
-  void set_fsid(uuid_d fsid);
+  void set_fsid(const uuid_d& fsid);
 
   void set_destination(const std::string& host, int port);
 
index 5300c4188dba26f0774c2d848f6d026950c86eab..237ce4bcf9d28578e5bc99d03bf24be1f06d6f3c 100644 (file)
@@ -16,6 +16,7 @@
 
 #include "include/types.h"
 #include "include/str_map.h"
+#include "include/uuid.h"
 
 #include "msg/Messenger.h"
 #include "msg/Message.h"
@@ -34,6 +35,9 @@
 #include <sys/mount.h>
 #endif // DARWIN
 
+#include "common/Graylog.h"
+// wipe the assert() introduced by boost headers included by Graylog.h
+#include "include/assert.h"
 #include "common/LogClient.h"
 
 #include "common/config.h"
index 84682ea88eb5461e93aebdd68090278f5ff6780a..3bb4e47301b47eb9410624168713310833ded85c 100644 (file)
@@ -17,8 +17,6 @@
 
 #include "common/LogEntry.h"
 #include "common/Mutex.h"
-#include "include/uuid.h"
-#include "common/Graylog.h"
 
 #include <iosfwd>
 #include <sstream>
@@ -29,10 +27,17 @@ class MLogAck;
 class Messenger;
 class MonMap;
 class Message;
+struct uuid_d;
 struct Connection;
 
 class LogChannel;
 
+namespace ceph {
+namespace log {
+  class Graylog;
+}
+}
+
 int parse_log_client_options(CephContext *cct,
                             map<string,string> &log_to_monitors,
                             map<string,string> &log_to_syslog,
@@ -177,7 +182,7 @@ private:
   std::string syslog_facility;
   bool log_to_syslog;
   bool log_to_monitors;
-  ceph::log::Graylog::Ref graylog;
+  shared_ptr<ceph::log::Graylog> graylog;
 
 
   friend class LogClientTemp;
index 5470807e9527c536ee53167a5c05f69ca2ca694c..259c2339a6ac441a51e0fec06a09b5b4ea43c252 100644 (file)
@@ -27,6 +27,7 @@
 #include "common/errno.h"
 #include "common/lockdep.h"
 #include "common/Formatter.h"
+#include "common/Graylog.h"
 #include "log/Log.h"
 #include "auth/Crypto.h"
 #include "include/str_list.h"
index 46dbb71466f4619f0cf234ebad27d0bc916a6b6a..1485b25df71586f6d334fb506a6515117fcbd45d 100644 (file)
@@ -17,6 +17,7 @@
 #include "common/errno.h"
 #include "common/safe_io.h"
 #include "common/Clock.h"
+#include "common/Graylog.h"
 #include "common/valgrind.h"
 #include "common/Formatter.h"
 #include "include/assert.h"
index ba2dc41d0572ea48b3e8345e2f306ed07d107c92..bfe5e40a87cb0728efdf531f0e98221f0241b841 100644 (file)
@@ -6,18 +6,17 @@
 
 #include "common/Thread.h"
 
-#include <assert.h>
 #include <pthread.h>
-#include <boost/asio.hpp>
 
 #include "Entry.h"
 #include "EntryQueue.h"
 #include "SubsystemMap.h"
-#include "common/Graylog.h"
 
 namespace ceph {
 namespace log {
 
+class Graylog;
+
 class Log : private Thread
 {
   Log **m_indirect_this;
@@ -42,7 +41,7 @@ class Log : private Thread
   int m_stderr_log, m_stderr_crash;
   int m_graylog_log, m_graylog_crash;
 
-  Graylog::Ref m_graylog;
+  shared_ptr<Graylog> m_graylog;
 
   bool m_stop;
 
@@ -78,7 +77,7 @@ public:
   void start_graylog();
   void stop_graylog();
 
-  Graylog::Ref graylog() { return m_graylog; }
+  shared_ptr<Graylog> graylog() { return m_graylog; }
 
   Entry *create_entry(int level, int subsys);
   Entry *create_entry(int level, int subsys, size_t* expected_size);
index 5aa66e2ad05404c0d3d711a559ebb068d0ac5024..391a3380b79ba8d89233336aa16b2bbd996a0323 100644 (file)
@@ -26,6 +26,7 @@
 #include "messages/MLogAck.h"
 
 #include "common/Timer.h"
+#include "common/Graylog.h"
 
 #include "osd/osd_types.h"
 #include "common/errno.h"
@@ -743,6 +744,32 @@ bool LogMonitor::log_channel_info::do_log_to_syslog(const string &channel) {
   return ret;
 }
 
+ceph::log::Graylog::Ref LogMonitor::log_channel_info::get_graylog(
+    const string &channel)
+{
+  generic_dout(25) << __func__ << " for channel '"
+                  << channel << "'" << dendl;
+
+  if (graylogs.count(channel) == 0) {
+    ceph::log::Graylog::Ref graylog = ceph::log::Graylog::Ref(new ceph::log::Graylog("mon"));
+
+    graylog->set_fsid(g_conf->fsid);
+    graylog->set_hostname(g_conf->host);
+    graylog->set_destination(get_str_map_key(log_to_graylog_host, channel,
+                                            &CLOG_CONFIG_DEFAULT_KEY),
+                            atoi(get_str_map_key(log_to_graylog_port, channel,
+                                                 &CLOG_CONFIG_DEFAULT_KEY).c_str()));
+
+    graylogs[channel] = graylog;
+    generic_dout(20) << __func__ << " for channel '"
+                    << channel << "' to graylog host '"
+                    << log_to_graylog_host[channel] << ":"
+                    << log_to_graylog_port[channel]
+                    << "'" << dendl;
+  }
+  return graylogs[channel];
+}
+
 void LogMonitor::handle_conf_change(const struct md_config_t *conf,
                                     const std::set<std::string> &changed)
 {
index d2e3a4a80231e2bee7f2c9a038ce7dd6cc15dedf..678c5ff3fc9ddc2e69c5aac710b5db883731e36e 100644 (file)
@@ -25,12 +25,17 @@ using namespace std;
 
 #include "common/LogEntry.h"
 #include "messages/MLog.h"
-#include "common/Graylog.h"
 
 class MMonCommand;
 
 static const string LOG_META_CHANNEL = "$channel";
 
+namespace ceph {
+namespace log {
+  class Graylog;
+}
+}
+
 class LogMonitor : public PaxosService,
                    public md_config_obs_t {
 private:
@@ -49,7 +54,7 @@ private:
     map<string,string> log_to_graylog_host;
     map<string,string> log_to_graylog_port;
 
-    map<string, ceph::log::Graylog::Ref> graylogs;
+    map<string, shared_ptr<ceph::log::Graylog>> graylogs;
     uuid_d fsid;
     string host;
 
@@ -120,29 +125,7 @@ private:
                              &CLOG_CONFIG_DEFAULT_KEY) == "true");
     }
 
-    ceph::log::Graylog::Ref get_graylog(const string &channel) {
-      generic_dout(25) << __func__ << " for channel '"
-                       << channel << "'" << dendl;
-
-      if (graylogs.count(channel) == 0) {
-       ceph::log::Graylog::Ref graylog = ceph::log::Graylog::Ref(new ceph::log::Graylog("mon"));
-
-       graylog->set_fsid(g_conf->fsid);
-       graylog->set_hostname(g_conf->host);
-       graylog->set_destination(get_str_map_key(log_to_graylog_host, channel,
-                                                &CLOG_CONFIG_DEFAULT_KEY),
-                                atoi(get_str_map_key(log_to_graylog_port, channel,
-                                                     &CLOG_CONFIG_DEFAULT_KEY).c_str()));
-
-       graylogs[channel] = graylog;
-        generic_dout(20) << __func__ << " for channel '"
-                         << channel << "' to graylog host '"
-                        << log_to_graylog_host[channel] << ":"
-                        << log_to_graylog_port[channel]
-                        << "'" << dendl;
-      }
-      return graylogs[channel];
-    }
+    shared_ptr<ceph::log::Graylog> get_graylog(const string &channel);
   } channels;
 
   void update_log_channels();