From: Casey Bodley Date: Thu, 6 Sep 2018 20:19:25 +0000 (-0400) Subject: dout: add basic prefix providers X-Git-Tag: v14.0.1~359^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c71493ad47f6a667ebb7b47ea35962620cbc42d1;p=ceph.git dout: add basic prefix providers adds two simple DoutPrefixProvider implementations for use as building blocks for composition with DoutPrefixPipe Signed-off-by: Casey Bodley --- diff --git a/src/common/dout.h b/src/common/dout.h index 2f7601d11dc..b96c7f09375 100644 --- a/src/common/dout.h +++ b/src/common/dout.h @@ -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;