From: Joao Eduardo Luis Date: Wed, 16 Jul 2014 17:04:29 +0000 (+0100) Subject: common: LogEntry: add 'channel' field X-Git-Tag: v0.86~167^2~17 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8a2bfcd88ead9f037c9bb2b27142e10c419d3c96;p=ceph.git common: LogEntry: add 'channel' field 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 --- diff --git a/src/common/LogEntry.cc b/src/common/LogEntry.cc index 235f0ed36d0c..9d6858ea2163 100644 --- a/src/common/LogEntry.cc +++ b/src/common/LogEntry.cc @@ -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); } diff --git a/src/common/LogEntry.h b/src/common/LogEntry.h index e9a1968e3776..293afe41bfc7 100644 --- a/src/common/LogEntry.h +++ b/src/common/LogEntry.h @@ -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 diff --git a/src/messages/MLogAck.h b/src/messages/MLogAck.h index 8022e7ced572..713cee003a20 100644 --- a/src/messages/MLogAck.h +++ b/src/messages/MLogAck.h @@ -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); } };