]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
dout: add basic prefix providers 23968/head
authorCasey Bodley <cbodley@redhat.com>
Thu, 6 Sep 2018 20:19:25 +0000 (16:19 -0400)
committerCasey Bodley <cbodley@redhat.com>
Thu, 6 Sep 2018 20:19:31 +0000 (16:19 -0400)
adds two simple DoutPrefixProvider implementations for use as building
blocks for composition with DoutPrefixPipe

Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/common/dout.h

index 2f7601d11dcb3e73256c928c2a26ade68532caab..b96c7f093758c4b0e099d51480ea481ba7437b4b 100644 (file)
@@ -44,6 +44,30 @@ public:
   virtual ~DoutPrefixProvider() {}
 };
 
+// a prefix provider with empty prefix
+class NoDoutPrefix : public DoutPrefixProvider {
+  CephContext *const cct;
+  const unsigned subsys;
+ public:
+  NoDoutPrefix(CephContext *cct, unsigned subsys) : cct(cct), subsys(subsys) {}
+
+  std::ostream& gen_prefix(std::ostream& out) const override { return out; }
+  CephContext *get_cct() const override { return cct; }
+  unsigned get_subsys() const override { return subsys; }
+};
+
+// a prefix provider with static (const char*) prefix
+class DoutPrefix : public NoDoutPrefix {
+  const char *const prefix;
+ public:
+  DoutPrefix(CephContext *cct, unsigned subsys, const char *prefix)
+    : NoDoutPrefix(cct, subsys), prefix(prefix) {}
+
+  std::ostream& gen_prefix(std::ostream& out) const override {
+    return out << prefix;
+  }
+};
+
 // a prefix provider that composes itself on top of another
 class DoutPrefixPipe : public DoutPrefixProvider {
   const DoutPrefixProvider& dpp;