]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
common: LogEntry: add 'channel' field
authorJoao Eduardo Luis <joao.luis@inktank.com>
Wed, 16 Jul 2014 17:04:29 +0000 (18:04 +0100)
committerJoao Eduardo Luis <joao.luis@inktank.com>
Wed, 27 Aug 2014 17:21:47 +0000 (18:21 +0100)
We now introduce the concept of 'channel', analogous to syslog
facilities, for log entries.  This will, shortly, allow a LogClient
to send messages to more than just the default syslog facility and log
file, also allowing multiple LogClients and having a way to associate
a LogEntry with its rightful owner.

We also add the same field to the MLogAck message so that a LogClient
waiting on a given ack is able to recognize the MLogAck as its own.

Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
src/common/LogEntry.cc
src/common/LogEntry.h
src/messages/MLogAck.h

index 235f0ed36d0c44e86b26fa36c4ef6b703123548d..9d6858ea216395dbcf527b13383fbcbd3db18b56 100644 (file)
@@ -161,19 +161,20 @@ void LogEntry::log_to_syslog(string level, string facility)
 
 void LogEntry::encode(bufferlist& bl) const
 {
-  ENCODE_START(2, 2, bl);
+  ENCODE_START(3, 2, bl);
   __u16 t = prio;
   ::encode(who, bl);
   ::encode(stamp, bl);
   ::encode(seq, bl);
   ::encode(t, bl);
   ::encode(msg, bl);
+  ::encode(channel, bl);
   ENCODE_FINISH(bl);
 }
 
 void LogEntry::decode(bufferlist::iterator& bl)
 {
-  DECODE_START_LEGACY_COMPAT_LEN(2, 2, 2, bl);
+  DECODE_START_LEGACY_COMPAT_LEN(3, 2, 2, bl);
   __u16 t;
   ::decode(who, bl);
   ::decode(stamp, bl);
@@ -181,6 +182,9 @@ void LogEntry::decode(bufferlist::iterator& bl)
   ::decode(t, bl);
   prio = (clog_type)t;
   ::decode(msg, bl);
+  if (struct_v >= 3) {
+    ::decode(channel, bl);
+  }
   DECODE_FINISH(bl);
 }
 
@@ -189,6 +193,7 @@ void LogEntry::dump(Formatter *f) const
   f->dump_stream("who") << who;
   f->dump_stream("stamp") << stamp;
   f->dump_unsigned("seq", seq);
+  f->dump_string("channel", channel);
   f->dump_stream("priority") << prio;
   f->dump_string("message", msg);
 }
index e9a1968e3776e783248c96b36844b626c48640d7..293afe41bfc7c93ec80c0318bb47a6cfd404cdad 100644 (file)
@@ -32,6 +32,11 @@ typedef enum {
   CLOG_ERROR = 4,
 } clog_type;
 
+static const std::string CLOG_CHANNEL_NONE    = "none";
+static const std::string CLOG_CHANNEL_DEFAULT = "default";
+static const std::string CLOG_CHANNEL_CLUSTER = "cluster";
+static const std::string CLOG_CHANNEL_AUDIT   = "audit";
+
 /*
  * Given a clog log_type, return the equivalent syslog priority
  */
@@ -42,6 +47,7 @@ int string_to_syslog_facility(string s);
 
 string clog_type_to_string(clog_type t);
 
+
 struct LogEntryKey {
   entity_inst_t who;
   utime_t stamp;
@@ -67,6 +73,7 @@ struct LogEntry {
   uint64_t seq;
   clog_type prio;
   string msg;
+  string channel;
 
   LogEntryKey key() const { return LogEntryKey(who, stamp, seq); }
 
@@ -127,7 +134,7 @@ inline ostream& operator<<(ostream& out, clog_type t)
 inline ostream& operator<<(ostream& out, const LogEntry& e)
 {
   return out << e.stamp << " " << e.who << " " << e.seq << " : "
-             << e.prio << " " << e.msg;
+             << e.channel << " " << e.prio << " " << e.msg;
 }
 
 #endif
index 8022e7ced572b64a43e966cc3fa562b94b46ceec..713cee003a20f8091d65accae942c59c5d6390f0 100644 (file)
@@ -21,7 +21,8 @@ class MLogAck : public Message {
 public:
   uuid_d fsid;
   version_t last;
-  
+  std::string channel;
+
   MLogAck() : Message(MSG_LOGACK) {}
   MLogAck(uuid_d& f, version_t l) : Message(MSG_LOGACK), fsid(f), last(l) {}
 private:
@@ -36,11 +37,14 @@ public:
   void encode_payload(uint64_t features) {
     ::encode(fsid, payload);
     ::encode(last, payload);
+    ::encode(channel, payload);
   }
   void decode_payload() {
     bufferlist::iterator p = payload.begin();
     ::decode(fsid, p);
     ::decode(last, p);
+    if (!p.end())
+      ::decode(channel, p);
   }
 };