]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr: allow logging to any channel
authorSage Weil <sage@redhat.com>
Sat, 22 Feb 2020 16:13:16 +0000 (10:13 -0600)
committerSage Weil <sage@redhat.com>
Thu, 27 Feb 2020 17:54:29 +0000 (11:54 -0600)
Signed-off-by: Sage Weil <sage@redhat.com>
src/mgr/ActivePyModules.cc
src/mgr/BaseMgrModule.cc
src/mon/MonClient.h

index e30da4cb0dd27085052925562e639f2ee39ee49e..b2f48acf3b28866999c83ab3d235b67326db9af7 100644 (file)
@@ -1074,11 +1074,25 @@ void ActivePyModules::cluster_log(const std::string &channel, clog_type prio,
 {
   std::lock_guard l(lock);
 
-  if (channel == "audit") {
-    audit_clog->do_log(prio, message);
-  } else {
-    clog->do_log(prio, message);
-  }
+  auto cl = monc.get_log_client()->create_channel(channel);
+  map<string,string> log_to_monitors;
+  map<string,string> log_to_syslog;
+  map<string,string> log_channel;
+  map<string,string> log_prio;
+  map<string,string> log_to_graylog;
+  map<string,string> log_to_graylog_host;
+  map<string,string> log_to_graylog_port;
+  uuid_d fsid;
+  string host;
+  if (parse_log_client_options(g_ceph_context, log_to_monitors, log_to_syslog,
+                              log_channel, log_prio, log_to_graylog,
+                              log_to_graylog_host, log_to_graylog_port,
+                              fsid, host) == 0)
+    cl->update_config(log_to_monitors, log_to_syslog,
+                     log_channel, log_prio, log_to_graylog,
+                     log_to_graylog_host, log_to_graylog_port,
+                     fsid, host);
+  cl->do_log(prio, message);
 }
 
 void ActivePyModules::register_client(std::string_view name, std::string addrs)
index e59c8e46d6c62dc569c465ca7489f7bee088ea0c..3ac66e9a9e77526a73cc6a7109e33111b9f86c06 100644 (file)
@@ -558,19 +558,11 @@ ceph_cluster_log(BaseMgrModule *self, PyObject *args)
   int prio = 0;
   char *channel = nullptr;
   char *message = nullptr;
-  std::vector<std::string> channels = { "audit", "cluster" };
 
   if (!PyArg_ParseTuple(args, "sis:ceph_cluster_log", &channel, &prio, &message)) {
     return nullptr;
   }
 
-  if (std::find(channels.begin(), channels.end(), std::string(channel)) == channels.end()) {
-    std::string msg("Unknown channel: ");
-    msg.append(channel);
-    PyErr_SetString(PyExc_ValueError, msg.c_str());
-    return nullptr;
-  }
-
   PyThreadState *tstate = PyEval_SaveThread();
   self->py_modules->cluster_log(channel, (clog_type)prio, message);
   PyEval_RestoreThread(tstate);
index 52c55fb18f321e8ef77b0e5af5426c1a7ce9ad36..7a080f564d48df9da9a6457534126d85d91e70c6 100644 (file)
@@ -426,6 +426,9 @@ public:
   void set_log_client(LogClient *clog) {
     log_client = clog;
   }
+  LogClient *get_log_client() {
+    return log_client;
+  }
 
   int build_initial_monmap();
   int get_monmap();