From: Samuel Just Date: Mon, 30 Mar 2015 23:46:10 +0000 (-0700) Subject: dout.h: add a DoutPrefixProvider and macro to allow passing of prefixes X-Git-Tag: v10.1.0~277^2~6 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b33dd14ec95d0db166930fbf1fa3580cbf9e9509;p=ceph.git dout.h: add a DoutPrefixProvider and macro to allow passing of prefixes This way, we can get proper logging within static functions. Signed-off-by: Samuel Just --- diff --git a/src/common/dout.h b/src/common/dout.h index 22befd67e0ce..9f8fd27dd3d1 100644 --- a/src/common/dout.h +++ b/src/common/dout.h @@ -39,6 +39,14 @@ inline std::ostream& operator<<(std::ostream& out, _bad_endl_use_dendl_t) { return out; } +class DoutPrefixProvider { +public: + virtual string gen_prefix() const = 0; + virtual CephContext *get_cct() const = 0; + virtual unsigned get_subsys() const = 0; + virtual ~DoutPrefixProvider() {} +}; + // generic macros #define dout_prefix *_dout @@ -58,6 +66,8 @@ inline std::ostream& operator<<(std::ostream& out, _bad_endl_use_dendl_t) { #define ldout(cct, v) dout_impl(cct, dout_subsys, v) dout_prefix #define lderr(cct) dout_impl(cct, ceph_subsys_, -1) dout_prefix +#define ldpp_dout(dpp, v) if (dpp) dout_impl(dpp->get_cct(), dpp->get_subsys(), v) (*_dout << dpp->gen_prefix()) + #define lgeneric_subdout(cct, sub, v) dout_impl(cct, ceph_subsys_##sub, v) *_dout #define lgeneric_dout(cct, v) dout_impl(cct, ceph_subsys_, v) *_dout #define lgeneric_derr(cct) dout_impl(cct, ceph_subsys_, -1) *_dout