From b33dd14ec95d0db166930fbf1fa3580cbf9e9509 Mon Sep 17 00:00:00 2001 From: Samuel Just Date: Mon, 30 Mar 2015 16:46:10 -0700 Subject: [PATCH] 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 --- src/common/dout.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/common/dout.h b/src/common/dout.h index 22befd67e0cec..9f8fd27dd3d1e 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 -- 2.39.5