]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/common/LogEntry.h
import 15.2.0 Octopus source
[ceph.git] / ceph / src / common / LogEntry.h
index 2501faf0437e4ec2c5db81776f66a8e07d48311e..3ef600b900a17e470c6cd9eb5110858005e9c972 100644 (file)
 #include "include/utime.h"
 #include "msg/msg_types.h"
 #include "common/entity_name.h"
+#include "ostream_temp.h"
 
 namespace ceph {
   class Formatter;
 }
 
-typedef enum {
-  CLOG_DEBUG = 0,
-  CLOG_INFO = 1,
-  CLOG_SEC = 2,
-  CLOG_WARN = 3,
-  CLOG_ERROR = 4,
-  CLOG_UNKNOWN = -1,
-} clog_type;
-
 static const std::string CLOG_CHANNEL_NONE    = "none";
 static const std::string CLOG_CHANNEL_DEFAULT = "cluster";
 static const std::string CLOG_CHANNEL_CLUSTER = "cluster";
@@ -46,11 +38,11 @@ static const std::string CLOG_CONFIG_DEFAULT_KEY = "default";
  */
 int clog_type_to_syslog_level(clog_type t);
 
-clog_type string_to_clog_type(const string& s);
-int string_to_syslog_level(string s);
-int string_to_syslog_facility(string s);
+clog_type string_to_clog_type(const std::string& s);
+int string_to_syslog_level(std::string s);
+int string_to_syslog_facility(std::string s);
 
-string clog_type_to_string(clog_type t);
+std::string clog_type_to_string(clog_type t);
 
 
 struct LogEntryKey {
@@ -58,7 +50,7 @@ private:
   uint64_t _hash = 0;
 
   void _calc_hash() {
-    hash<entity_name_t> h;
+    std::hash<entity_name_t> h;
     _hash = seq + h(rank);
   }
 
@@ -77,8 +69,8 @@ public:
     return _hash;
   }
 
-  void dump(Formatter *f) const;
-  static void generate_test_instances(list<LogEntryKey*>& o);
+  void dump(ceph::Formatter *f) const;
+  static void generate_test_instances(std::list<LogEntryKey*>& o);
 
   friend bool operator==(const LogEntryKey& l, const LogEntryKey& r) {
     return l.rank == r.rank && l.stamp == r.stamp && l.seq == r.seq;
@@ -86,11 +78,11 @@ public:
 };
 
 namespace std {
-  template<> struct hash<LogEntryKey> {
-    size_t operator()(const LogEntryKey& r) const {
-      return r.get_hash();
-    }
-  };
+template<> struct hash<LogEntryKey> {
+  size_t operator()(const LogEntryKey& r) const {
+    return r.get_hash();
+  }
+};
 } // namespace std
 
 struct LogEntry {
@@ -100,19 +92,19 @@ struct LogEntry {
   utime_t stamp;
   uint64_t seq;
   clog_type prio;
-  string msg;
-  string channel;
+  std::string msg;
+  std::string channel;
 
   LogEntry() : seq(0), prio(CLOG_DEBUG) {}
 
   LogEntryKey key() const { return LogEntryKey(rank, stamp, seq); }
 
-  void log_to_syslog(string level, string facility);
+  void log_to_syslog(std::string level, std::string facility);
 
-  void encode(bufferlist& bl, uint64_t features) const;
-  void decode(bufferlist::const_iterator& bl);
-  void dump(Formatter *f) const;
-  static void generate_test_instances(list<LogEntry*>& o);
+  void encode(ceph::buffer::list& bl, uint64_t features) const;
+  void decode(ceph::buffer::list::const_iterator& bl);
+  void dump(ceph::Formatter *f) const;
+  static void generate_test_instances(std::list<LogEntry*>& o);
   static clog_type str_to_level(std::string const &str);
 };
 WRITE_CLASS_ENCODER_FEATURES(LogEntry)
@@ -120,17 +112,17 @@ WRITE_CLASS_ENCODER_FEATURES(LogEntry)
 struct LogSummary {
   version_t version;
   // channel -> [(seq#, entry), ...]
-  map<string,list<pair<uint64_t,LogEntry>>> tail_by_channel;
+  std::map<std::string,std::list<std::pair<uint64_t,LogEntry>>> tail_by_channel;
   uint64_t seq = 0;
   ceph::unordered_set<LogEntryKey> keys;
 
   LogSummary() : version(0) {}
 
-  void build_ordered_tail(list<LogEntry> *tail) const;
+  void build_ordered_tail(std::list<LogEntry> *tail) const;
 
   void add(const LogEntry& e) {
     keys.insert(e.key());
-    tail_by_channel[e.channel].push_back(make_pair(++seq, e));
+    tail_by_channel[e.channel].push_back(std::make_pair(++seq, e));
   }
   void prune(size_t max) {
     for (auto& i : tail_by_channel) {
@@ -144,14 +136,14 @@ struct LogSummary {
     return keys.count(k);
   }
 
-  void encode(bufferlist& bl, uint64_t features) const;
-  void decode(bufferlist::const_iterator& bl);
-  void dump(Formatter *f) const;
-  static void generate_test_instances(list<LogSummary*>& o);
+  void encode(ceph::buffer::list& bl, uint64_t features) const;
+  void decode(ceph::buffer::list::const_iterator& bl);
+  void dump(ceph::Formatter *f) const;
+  static void generate_test_instances(std::list<LogSummary*>& o);
 };
 WRITE_CLASS_ENCODER_FEATURES(LogSummary)
 
-inline ostream& operator<<(ostream& out, const clog_type t)
+inline std::ostream& operator<<(std::ostream& out, const clog_type t)
 {
   switch (t) {
   case CLOG_DEBUG:
@@ -169,7 +161,7 @@ inline ostream& operator<<(ostream& out, const clog_type t)
   }
 }
 
-inline ostream& operator<<(ostream& out, const LogEntry& e)
+inline std::ostream& operator<<(std::ostream& out, const LogEntry& e)
 {
   return out << e.stamp << " " << e.name << " (" << e.rank << ") "
             << e.seq << " : "